Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-12 03:18:08
Exec Total Coverage
Lines: 1644 4178 39.3%
Functions: 129 329 39.2%
Branches: 886 2710 32.7%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "tiles.h"
37 #include "base/colors.h"
38 #include "pal.h"
39 #include "base/zsys.h"
40 #include "qst.h"
41 #include "zc/zc_sys.h"
42 #include "play_midi.h"
43 #include "jwin_a5.h"
44 #include "base/jwinfsel.h"
45 #include "base/gui.h"
46 #include "midi.h"
47 #include "subscr.h"
48 #include "zc/maps.h"
49 #include "sprite.h"
50 #include "zc/guys.h"
51 #include "zc/hero.h"
52 #include "zc/title.h"
53 #include "particles.h"
54 #include "zcmusic.h"
55 #include "zconsole.h"
56 #include "zc/ffscript.h"
57 #include "dialog/info.h"
58 #include "dialog/alert.h"
59 #include "zc/combos.h"
60 #include "zc/jit.h"
61 #include <fmt/format.h>
62 #include "zinfo.h"
63 #include "base/misctypes.h"
64
65 #ifdef __EMSCRIPTEN__
66 #include "base/emscripten_utils.h"
67 #endif
68
69 extern FFScript FFCore;
70 extern bool Playing;
71 int32_t sfx_voice[WAV_COUNT];
72 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
73 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
74
75 extern byte monochrome_console;
76
77 extern HeroClass Hero;
78 extern FFScript FFCore;
79 extern ZModule zcm;
80 extern zcmodule moduledata;
81 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
82 extern particle_list particles;
83 extern int32_t loadlast;
84 extern char *sfx_string[WAV_COUNT];
85 byte use_dwm_flush;
86 byte use_save_indicator;
87 int32_t paused_midi_pos = 0;
88 byte midi_suspended = 0;
89 byte zc_192b163_warp_compatibility;
90 char modulepath[2048];
91 bool epilepsyFlashReduction;
92 signed char pause_in_background_menu_init = 0;
93 byte pause_in_background = 0;
94 bool is_sys_pal = false;
95 static bool load_control_called_this_frame;
96 extern PALETTE* hw_palette;
97 extern bool update_hw_pal;
98 extern const char* dmaplist(int32_t index, int32_t* list_size);
99 int32_t getnumber(const char *prompt,int32_t initialval);
100
101 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
102 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
103 //extern byte refresh_select_screen;
104 //extern movingblock mblock2; //mblock[4]?
105 //extern int32_t db;
106
107 static const char *ZC_str = "ZQuest Classic";
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 83751 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 46 void load_default_cheatkeys()
296 {
297 46 memset(cheatkeys, 0, sizeof(cheatkeys));
298 46 cheatkeys[Cheat::Life][0] = KEY_H;
299 46 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 46 cheatkeys[Cheat::Magic][0] = KEY_M;
301 46 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 46 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 46 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 46 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 46 cheatkeys[Cheat::Clock][0] = KEY_I;
306 46 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 46 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 46 cheatkeys[Cheat::Light][0] = KEY_L;
309 46 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 46 cheatkeys[Cheat::Kill][0] = KEY_K;
311 46 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 46 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 46 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 46 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 46 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 46 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 46 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 46 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 46 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 46 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 46 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 46 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 46 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 46 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 46 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 46 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 46 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 46 }
329 46 void load_game_configs()
330 {
331 46 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 46 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 46 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 46 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 46 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 46 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 46 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 46 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 46 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 46 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 46 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 46 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 46 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 46 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 46 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 46 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 46 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 46 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 46 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 46 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 1610 times.
✓ Branch 1 taken 46 times.
1656 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 if(!bindable_cheat((Cheat)q)) continue;
359 1610 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 util::lowerstr(cheatname);
361 1610 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1610 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 1610 }
366
367
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 46 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 46 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 46 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 46 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 46 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 46 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 46 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 46 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 46 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 46 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 46 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 46 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 46 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 46 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 46 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 46 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 46 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 46 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 46 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 46 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 46 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 46 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 46 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 46 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 46 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 46 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 46 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 46 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 46 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 46 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 46 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 46 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 46 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 46 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 46 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 46 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 46 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 46 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 46 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 46 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 46 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 46 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 46 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 46 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 46 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 46 title_version = zc_get_config(cfg_sect,"title",2);
425 46 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 46 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 46 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 46 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 46 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 46 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 46 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 46 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 46 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 46 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 46 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 46 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 46 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 46 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 46 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 46 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 46 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 46 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 46 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 46 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(strlen(qstdir)==0)
466 {
467 46 getcwd(qstdir,2048);
468 46 fix_filename_case(qstdir);
469 46 fix_filename_slashes(qstdir);
470 46 put_backslash(qstdir);
471 46 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 46 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 46 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 46 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 46 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 46 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 46 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 46 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 46 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 46 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 46 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 46 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
597
598 flush_config_file();
599 #ifdef __EMSCRIPTEN__
600 em_sync_fs();
601 #endif
602 }
603
604 //----------------------------------------------------------------
605
606 // Timers
607
608 28626 void fps_callback()
609 {
610 28626 lastfps=framecnt;
611 28626 dword tempsecs = fps_secs;
612 28626 ++tempsecs;
613 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
614 28626 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
615 28626 ++fps_secs;
616 28626 framecnt=0;
617 28626 }
618
619 END_OF_FUNCTION(fps_callback)
620
621 46 int32_t Z_init_timers()
622 {
623 static bool didit = false;
624 const static char *err_str = "Couldn't allocate timer";
625 46 err_str = err_str; //Unused variable warning
626
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(didit)
628 return 1;
629
630 46 didit = true;
631
632 LOCK_VARIABLE(lastfps);
633 LOCK_VARIABLE(framecnt);
634 LOCK_FUNCTION(fps_callback);
635
636
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
637 return 0;
638
639 46 return 1;
640 46 }
641
642 void Z_remove_timers()
643 {
644 remove_int(fps_callback);
645 }
646
647 //----------------------------------------------------------------
648
649 void go()
650 {
651 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
652 }
653
654 void comeback()
655 {
656 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
657 }
658
659 void dump_pal(BITMAP *dest)
660 {
661 for(int32_t i=0; i<256; i++)
662 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
663 }
664
665 //----------------------------------------------------------------
666
667 int game_mouse_index = ZCM_BLANK;
668 static bool system_mouse = false;
669 26 bool sys_mouse()
670 {
671 26 system_mouse = true;
672 26 return MouseSprite::set(ZCM_NORMAL);
673 }
674 555 bool game_mouse()
675 {
676 555 system_mouse = false;
677 555 return MouseSprite::set(game_mouse_index);
678 }
679 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
680 {
681 if(!bmp)
682 return;
683 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
684 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
685 if(bmp->w == scaledw && bmp->h == scaledh)
686 user_scale = false;
687 if(user_scale || sys_recolor)
688 {
689 if(!user_scale) scale = 1;
690 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
691 if(user_scale)
692 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
693 else
694 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
695 if(sys_recolor)
696 recolor_mouse(tmpbmp);
697 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
698 destroy_bitmap(tmpbmp);
699 }
700 else
701 {
702 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
703 }
704 }
705
706 //Handles converting the mouse sprite from the .dat file
707 void recolor_mouse(BITMAP* bmp)
708 {
709 for(int32_t x = 0; x < bmp->w; ++x)
710 {
711 for(int32_t y = 0; y < bmp->h; ++y)
712 {
713 int32_t color = getpixel(bmp, x, y);
714 switch(color)
715 {
716 case dvc(1):
717 color = jwin_pal[jcCURSORMISC];
718 break;
719 case dvc(2):
720 color = jwin_pal[jcCURSOROUTLINE];
721 break;
722 case dvc(3):
723 color = jwin_pal[jcCURSORLIGHT];
724 break;
725 case dvc(5):
726 color = jwin_pal[jcCURSORDARK];
727 break;
728 default:
729 continue;
730 }
731 putpixel(bmp, x, y, color);
732 }
733 }
734 }
735 void load_mouse()
736 {
737 enter_sys_pal();
738 MouseSprite::set(-1);
739 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
740 int32_t sz = 16*scale;
741 for(int32_t j = 0; j < 1; ++j)
742 {
743 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
744 if(zcmouse[j])
745 destroy_bitmap(zcmouse[j]);
746 zcmouse[j] = create_bitmap_ex(8,sz,sz);
747 clear_bitmap(zcmouse[j]);
748 clear_bitmap(tmpbmp);
749 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
750 recolor_mouse(tmpbmp);
751 if(sz!=16)
752 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
753 else
754 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
755 destroy_bitmap(tmpbmp);
756 }
757 if(!hw_palette) hw_palette = &RAMpal;
758 zc_set_palette(*hw_palette);
759
760 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
761 clear_bitmap(blankmouse);
762
763 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
764 MouseSprite::assign(ZCM_BLANK, blankmouse);
765 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
766
767 //Reload the mouse
768 if(system_mouse)
769 sys_mouse();
770 else game_mouse();
771
772 destroy_bitmap(blankmouse);
773 exit_sys_pal();
774 }
775
776 // sets the video mode and initializes the palette and mouse sprite
777 46 bool game_vid_mode(int32_t mode,int32_t wait)
778 {
779
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (is_headless())
780 46 return true;
781
782 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 scrx = (resx-320)>>1;
788 scry = (resy-240)>>1;
789 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 zcmouse[q] = NULL;
791 load_mouse();
792
793 for(int32_t i=240; i<256; i++)
794 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 zc_set_palette(RAMpal);
797 clear_to_color(screen,BLACK);
798
799 rest(wait);
800 return true;
801 46 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string, "modules/classic/default.qst");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
818 8 }
819
820 8 void init_NES_mode()
821 {
822 8 null_quest();
823 8 }
824
825 //----------------------------------------------------------------
826
827 qword trianglelines[16]=
828 {
829 0x0000000000000000ULL,
830 0xFD00000000000000ULL,
831 0xFDFD000000000000ULL,
832 0xFDFDFD0000000000ULL,
833 0xFDFDFDFD00000000ULL,
834 0xFDFDFDFDFD000000ULL,
835 0xFDFDFDFDFDFD0000ULL,
836 0xFDFDFDFDFDFDFD00ULL,
837 0xFDFDFDFDFDFDFDFDULL,
838 0x00FDFDFDFDFDFDFDULL,
839 0x0000FDFDFDFDFDFDULL,
840 0x000000FDFDFDFDFDULL,
841 0x00000000FDFDFDFDULL,
842 0x0000000000FDFDFDULL,
843 0x000000000000FDFDULL,
844 0x00000000000000FDULL,
845 };
846
847 word screen_triangles[28][32];
848 /*
849 qword triangles[4][16]= //[direction][value]
850 {
851 {
852 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
853 },
854 {
855 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
856 },
857 {
858 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
859 },
860 {
861 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
862 }
863 };
864 */
865
866
867 /*
868 byte triangles[4][16][8]= //[direction][value][line]
869 {
870 {
871 {
872 0, 0, 0, 0, 0, 0, 0, 0
873 },
874 {
875 1, 0, 0, 0, 0, 0, 0, 0
876 },
877 {
878 2, 1, 0, 0, 0, 0, 0, 0
879 },
880 {
881 3, 2, 1, 0, 0, 0, 0, 0
882 },
883 {
884 4, 3, 2, 1, 0, 0, 0, 0
885 },
886 {
887 5, 4, 3, 2, 1, 0, 0, 0
888 },
889 {
890 6, 5, 4, 3, 2, 1, 0, 0
891 },
892 {
893 7, 6, 5, 4, 3, 2, 1, 0
894 },
895 {
896 8, 7, 6, 5, 4, 3, 2, 1
897 },
898 {
899 8, 8, 7, 6, 5, 4, 3, 2
900 },
901 {
902 8, 8, 8, 7, 6, 5, 4, 3
903 },
904 {
905 8, 8, 8, 8, 7, 6, 5, 4
906 },
907 {
908 8, 8, 8, 8, 8, 7, 6, 5
909 },
910 {
911 8, 8, 8, 8, 8, 8, 7, 6
912 },
913 {
914 8, 8, 8, 8, 8, 8, 8, 7
915 },
916 {
917 8, 8, 8, 8, 8, 8, 8, 8
918 }
919 },
920 {
921 {
922 0, 0, 0, 0, 0, 0, 0, 0
923 },
924 {
925 15, 0, 0, 0, 0, 0, 0, 0
926 },
927 {
928 14, 15, 0, 0, 0, 0, 0, 0
929 },
930 {
931 13, 14, 15, 0, 0, 0, 0, 0
932 },
933 {
934 12, 13, 14, 15, 0, 0, 0, 0
935 },
936 {
937 11, 12, 13, 14, 15, 0, 0, 0
938 },
939 {
940 10, 11, 12, 13, 14, 15, 0, 0
941 },
942 {
943 9, 10, 11, 12, 13, 14, 15, 0
944 },
945 {
946 8, 9, 10, 11, 12, 13, 14, 15
947 },
948 {
949 8, 8, 9, 10, 11, 12, 13, 14
950 },
951 {
952 8, 8, 8, 9, 10, 11, 12, 13
953 },
954 {
955 8, 8, 8, 8, 9, 10, 11, 12
956 },
957 {
958 8, 8, 8, 8, 8, 9, 10, 11
959 },
960 {
961 8, 8, 8, 8, 8, 8, 9, 10
962 },
963 {
964 8, 8, 8, 8, 8, 8, 8, 9
965 },
966 {
967 8, 8, 8, 8, 8, 8, 8, 8
968 }
969 },
970 {
971 {
972 0, 0, 0, 0, 0, 0, 0, 0
973 },
974 {
975 0, 0, 0, 0, 0, 0, 0, 1
976 },
977 {
978 0, 0, 0, 0, 0, 0, 1, 2
979 },
980 {
981 0, 0, 0, 0, 0, 1, 2, 3
982 },
983 {
984 0, 0, 0, 0, 1, 2, 3, 4
985 },
986 {
987 0, 0, 0, 1, 2, 3, 4, 5
988 },
989 {
990 0, 0, 1, 2, 3, 4, 5, 6
991 },
992 {
993 0, 1, 2, 3, 4, 5, 6, 7
994 },
995 {
996 1, 2, 3, 4, 5, 6, 7, 8
997 },
998 {
999 2, 3, 4, 5, 6, 7, 8, 8
1000 },
1001 {
1002 3, 4, 5, 6, 7, 8, 8, 8
1003 },
1004 {
1005 4, 5, 6, 7, 8, 8, 8, 8
1006 },
1007 {
1008 5, 6, 7, 8, 8, 8, 8, 8
1009 },
1010 {
1011 6, 7, 8, 8, 8, 8, 8, 8
1012 },
1013 {
1014 7, 8, 8, 8, 8, 8, 8, 8
1015 },
1016 {
1017 8, 8, 8, 8, 8, 8, 8, 8
1018 }
1019 },
1020 {
1021 {
1022 0, 0, 0, 0, 0, 0, 0, 0
1023 },
1024 {
1025 0, 0, 0, 0, 0, 0, 0, 15
1026 },
1027 {
1028 0, 0, 0, 0, 0, 0, 15, 14
1029 },
1030 {
1031 0, 0, 0, 0, 0, 15, 14, 13
1032 },
1033 {
1034 0, 0, 0, 0, 15, 14, 13, 12
1035 },
1036 {
1037 0, 0, 0, 15, 14, 13, 12, 11
1038 },
1039 {
1040 0, 0, 15, 14, 13, 12, 11, 10
1041 },
1042 {
1043 0, 15, 14, 13, 12, 11, 10, 9
1044 },
1045 {
1046 15, 14, 13, 12, 11, 10, 9, 8
1047 },
1048 {
1049 14, 13, 12, 11, 10, 9, 8, 8
1050 },
1051 {
1052 13, 12, 11, 10, 9, 8, 8, 8
1053 },
1054 {
1055 12, 11, 10, 9, 8, 8, 8, 8
1056 },
1057 {
1058 11, 10, 9, 8, 8, 8, 8, 8
1059 },
1060 {
1061 10, 9, 8, 8, 8, 8, 8, 8
1062 },
1063 {
1064 9, 8, 8, 8, 8, 8, 8, 8
1065 },
1066 {
1067 8, 8, 8, 8, 8, 8, 8, 8
1068 }
1069 }
1070 };
1071 */
1072
1073
1074
1075 /*
1076 for (int32_t blockrow=0; blockrow<30; ++i)
1077 {
1078 for (int32_t linerow=0; linerow<8; ++i)
1079 {
1080 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1081 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1082 {
1083 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1084 ++triangleline;
1085 }
1086 }
1087 }
1088 */
1089
1090 // the ULL suffixes are to prevent this warning:
1091 // warning: integer constant is too large for "int32_t" type
1092
1093 qword triangles[4][16][8]= //[direction][value][line]
1094 {
1095 {
1096 {
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFD00000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFD000000000000ULL,
1118 0xFD00000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFD0000000000ULL,
1128 0xFDFD000000000000ULL,
1129 0xFD00000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFD00000000ULL,
1138 0xFDFDFD0000000000ULL,
1139 0xFDFD000000000000ULL,
1140 0xFD00000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFD000000ULL,
1148 0xFDFDFDFD00000000ULL,
1149 0xFDFDFD0000000000ULL,
1150 0xFDFD000000000000ULL,
1151 0xFD00000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFD0000ULL,
1158 0xFDFDFDFDFD000000ULL,
1159 0xFDFDFDFD00000000ULL,
1160 0xFDFDFD0000000000ULL,
1161 0xFDFD000000000000ULL,
1162 0xFD00000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFD00ULL,
1168 0xFDFDFDFDFDFD0000ULL,
1169 0xFDFDFDFDFD000000ULL,
1170 0xFDFDFDFD00000000ULL,
1171 0xFDFDFD0000000000ULL,
1172 0xFDFD000000000000ULL,
1173 0xFD00000000000000ULL,
1174 0x0000000000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFD00ULL,
1179 0xFDFDFDFDFDFD0000ULL,
1180 0xFDFDFDFDFD000000ULL,
1181 0xFDFDFDFD00000000ULL,
1182 0xFDFDFD0000000000ULL,
1183 0xFDFD000000000000ULL,
1184 0xFD00000000000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFD00ULL,
1190 0xFDFDFDFDFDFD0000ULL,
1191 0xFDFDFDFDFD000000ULL,
1192 0xFDFDFDFD00000000ULL,
1193 0xFDFDFD0000000000ULL,
1194 0xFDFD000000000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFD00ULL,
1201 0xFDFDFDFDFDFD0000ULL,
1202 0xFDFDFDFDFD000000ULL,
1203 0xFDFDFDFD00000000ULL,
1204 0xFDFDFD0000000000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFD00ULL,
1212 0xFDFDFDFDFDFD0000ULL,
1213 0xFDFDFDFDFD000000ULL,
1214 0xFDFDFDFD00000000ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFD00ULL,
1223 0xFDFDFDFDFDFD0000ULL,
1224 0xFDFDFDFDFD000000ULL
1225 },
1226 {
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFD00ULL,
1234 0xFDFDFDFDFDFD0000ULL
1235 },
1236 {
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFD00ULL
1245 },
1246 {
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL
1255 }
1256 },
1257 {
1258 {
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000000000FDULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000000000FDFDULL,
1280 0x00000000000000FDULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000000000FDFDFDULL,
1290 0x000000000000FDFDULL,
1291 0x00000000000000FDULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00000000FDFDFDFDULL,
1300 0x0000000000FDFDFDULL,
1301 0x000000000000FDFDULL,
1302 0x00000000000000FDULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0x000000FDFDFDFDFDULL,
1310 0x00000000FDFDFDFDULL,
1311 0x0000000000FDFDFDULL,
1312 0x000000000000FDFDULL,
1313 0x00000000000000FDULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL
1317 },
1318 {
1319 0x0000FDFDFDFDFDFDULL,
1320 0x000000FDFDFDFDFDULL,
1321 0x00000000FDFDFDFDULL,
1322 0x0000000000FDFDFDULL,
1323 0x000000000000FDFDULL,
1324 0x00000000000000FDULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL
1327 },
1328 {
1329 0x00FDFDFDFDFDFDFDULL,
1330 0x0000FDFDFDFDFDFDULL,
1331 0x000000FDFDFDFDFDULL,
1332 0x00000000FDFDFDFDULL,
1333 0x0000000000FDFDFDULL,
1334 0x000000000000FDFDULL,
1335 0x00000000000000FDULL,
1336 0x0000000000000000ULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0x00FDFDFDFDFDFDFDULL,
1341 0x0000FDFDFDFDFDFDULL,
1342 0x000000FDFDFDFDFDULL,
1343 0x00000000FDFDFDFDULL,
1344 0x0000000000FDFDFDULL,
1345 0x000000000000FDFDULL,
1346 0x00000000000000FDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0x00FDFDFDFDFDFDFDULL,
1352 0x0000FDFDFDFDFDFDULL,
1353 0x000000FDFDFDFDFDULL,
1354 0x00000000FDFDFDFDULL,
1355 0x0000000000FDFDFDULL,
1356 0x000000000000FDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0x00FDFDFDFDFDFDFDULL,
1363 0x0000FDFDFDFDFDFDULL,
1364 0x000000FDFDFDFDFDULL,
1365 0x00000000FDFDFDFDULL,
1366 0x0000000000FDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0x00FDFDFDFDFDFDFDULL,
1374 0x0000FDFDFDFDFDFDULL,
1375 0x000000FDFDFDFDFDULL,
1376 0x00000000FDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0x00FDFDFDFDFDFDFDULL,
1385 0x0000FDFDFDFDFDFDULL,
1386 0x000000FDFDFDFDFDULL
1387 },
1388 {
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0x00FDFDFDFDFDFDFDULL,
1396 0x0000FDFDFDFDFDFDULL
1397 },
1398 {
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0x00FDFDFDFDFDFDFDULL
1407 },
1408 {
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL
1417 }
1418 },
1419 {
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL
1469 },
1470 {
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL
1479 },
1480 {
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0xFD00000000000000ULL,
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL
1489 },
1490 {
1491 0x0000000000000000ULL,
1492 0xFD00000000000000ULL,
1493 0xFDFD000000000000ULL,
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL
1499 },
1500 {
1501 0xFD00000000000000ULL,
1502 0xFDFD000000000000ULL,
1503 0xFDFDFD0000000000ULL,
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFD000000000000ULL,
1512 0xFDFDFD0000000000ULL,
1513 0xFDFDFDFD00000000ULL,
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFD0000000000ULL,
1522 0xFDFDFDFD00000000ULL,
1523 0xFDFDFDFDFD000000ULL,
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFD00000000ULL,
1532 0xFDFDFDFDFD000000ULL,
1533 0xFDFDFDFDFDFD0000ULL,
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFD000000ULL,
1542 0xFDFDFDFDFDFD0000ULL,
1543 0xFDFDFDFDFDFDFD00ULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 },
1550 {
1551 0xFDFDFDFDFDFD0000ULL,
1552 0xFDFDFDFDFDFDFD00ULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL
1559 },
1560 {
1561 0xFDFDFDFDFDFDFD00ULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL
1569 },
1570 {
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL
1579 }
1580 },
1581 {
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL
1631 },
1632 {
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL
1641 },
1642 {
1643 0x0000000000000000ULL,
1644 0x0000000000000000ULL,
1645 0x00000000000000FDULL,
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000000000ULL,
1654 0x00000000000000FDULL,
1655 0x000000000000FDFDULL,
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000000000FDULL,
1664 0x000000000000FDFDULL,
1665 0x0000000000FDFDFDULL,
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000000000FDFDULL,
1674 0x0000000000FDFDFDULL,
1675 0x00000000FDFDFDFDULL,
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000000000FDFDFDULL,
1684 0x00000000FDFDFDFDULL,
1685 0x000000FDFDFDFDFDULL,
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00000000FDFDFDFDULL,
1694 0x000000FDFDFDFDFDULL,
1695 0x0000FDFDFDFDFDFDULL,
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0x000000FDFDFDFDFDULL,
1704 0x0000FDFDFDFDFDFDULL,
1705 0x00FDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 },
1712 {
1713 0x0000FDFDFDFDFDFDULL,
1714 0x00FDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL
1721 },
1722 {
1723 0x00FDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL
1731 },
1732 {
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL
1741 }
1742 }
1743 };
1744
1745 int32_t black_opening_count=0;
1746 int32_t black_opening_x,black_opening_y;
1747 int32_t black_opening_shape;
1748
1749 1506 int32_t choose_opening_shape()
1750 {
1751 // First, count how many bits are set
1752 1506 int32_t numBits=0;
1753 int32_t bitCounter;
1754
1755
2/2
✓ Branch 0 taken 7530 times.
✓ Branch 1 taken 1506 times.
9036 for(int32_t i=0; i<bosMAX; i++)
1756 {
1757
2/2
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 1722 times.
7530 if(COOLSCROLL&(1<<i))
1758 1722 numBits++;
1759 7530 }
1760
1761 // Shouldn't happen...
1762
1/2
✓ Branch 0 taken 1506 times.
✗ Branch 1 not taken.
1506 if(numBits==0)
1763 return bosCIRCLE;
1764
1765 // Pick a bit
1766 1506 bitCounter=zc_rand()%numBits+1;
1767
1768
2/2
✓ Branch 0 taken 1991 times.
✓ Branch 1 taken 26 times.
2017 for(int32_t i=0; i<bosMAX; i++)
1769 {
1770 // If this bit is set, decrement the bit counter
1771
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1636 times.
1991 if(COOLSCROLL&(1<<i))
1772 1636 bitCounter--;
1773
1774 // When the counter hits 0, return a value based on
1775 // which bit it stopped on.
1776 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1777
2/2
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 511 times.
1991 if(bitCounter==0)
1778 1480 return i;
1779 511 }
1780
1781 // Shouldn't be necessary, but the compiler might complain, at least
1782 26 return bosCIRCLE;
1783 1506 }
1784
1785 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1786 {
1787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1788
1789 396 int32_t w=256, h=224;
1790 396 int32_t blockrows=28, blockcolumns=32;
1791 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1792
1793
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1794 {
1795
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1796 {
1797
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1798 354816 }
1799 11088 }
1800
1801 396 black_opening_count = 66;
1802 396 black_opening_x = x;
1803 396 black_opening_y = y;
1804 396 lensclk = 0;
1805 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1806
1807
1808
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1809 {
1810 refreshTints();
1811 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1812 }
1813
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1814 {
1815 FFCore.warpScriptCheck();
1816 for(int32_t i=0; i<66; i++)
1817 {
1818 draw_screen(tmpscr);
1819 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1820 advanceframe(true);
1821
1822 if(Quit)
1823 {
1824 break;
1825 }
1826 }
1827 }
1828 396 }
1829
1830 1110 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1831 {
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110 times.
1110 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1833
1834 1110 int32_t w=256, h=224;
1835 1110 int32_t blockrows=28, blockcolumns=32;
1836 1110 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1837
1838
2/2
✓ Branch 0 taken 31080 times.
✓ Branch 1 taken 1110 times.
32190 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1839 {
1840
2/2
✓ Branch 0 taken 994560 times.
✓ Branch 1 taken 31080 times.
1025640 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1841 {
1842
2/2
✓ Branch 0 taken 442260 times.
✓ Branch 1 taken 552300 times.
994560 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1843 994560 }
1844 31080 }
1845
1846 1110 black_opening_count = -66;
1847 1110 black_opening_x = x;
1848 1110 black_opening_y = y;
1849 1110 lensclk = 0;
1850
1/2
✓ Branch 0 taken 1110 times.
✗ Branch 1 not taken.
1110 if(black_opening_shape == bosFADEBLACK)
1851 {
1852 refreshTints();
1853 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1854 }
1855
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 911 times.
1110 if(wait)
1856 {
1857 911 FFCore.warpScriptCheck();
1858
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 60126 times.
61037 for(int32_t i=0; i<66; i++)
1859 {
1860 60126 draw_screen(tmpscr);
1861 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1862 60126 advanceframe(true);
1863
1864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60126 times.
60126 if(Quit)
1865 {
1866 break;
1867 }
1868 60126 }
1869 911 }
1870 1110 }
1871
1872 99396 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1873 {
1874 99396 clear_to_color(tmp_scr,BLACK);
1875 99396 int32_t w=256, h=224;
1876
1877
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90222 times.
99396 switch(black_opening_shape)
1878 {
1879 case bosOVAL:
1880 {
1881 858 double new_w=(w/2)+abs(w/2-x);
1882 858 double new_h=(h/2)+abs(h/2-y);
1883 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1884 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1885 858 break;
1886 }
1887
1888 case bosTRIANGLE:
1889 {
1890 660 double new_w=(w/2)+abs(w/2-x);
1891 660 double new_h=(h/2)+abs(h/2-y);
1892 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1893 660 double P2= (PI/2);
1894 660 double P23=(2*PI/3);
1895 660 double P43=(4*PI/3);
1896 660 double Pa= (-4*PI*a/(3*max_a));
1897 660 double angle=P2+Pa;
1898 660 double a0=angle;
1899 660 double a2=angle+P23;
1900 660 double a4=angle+P43;
1901 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1902 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1903 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1904 0);
1905 660 break;
1906 }
1907
1908 case bosSMAS:
1909 {
1910
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1911
1912
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1913 {
1914
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1915 {
1916 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1917
1918
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1919 {
1920 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1921
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1922 54878208 [linerow];
1923 54878208 ++triangleline;
1924
1925
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1926 {
1927 6859776 }
1928 54878208 }
1929 1714944 }
1930 214368 }
1931
1932 7656 break;
1933 }
1934
1935 case bosFADEBLACK:
1936 {
1937 if(black_opening_count<0)
1938 {
1939 black_fade(zc_min(-black_opening_count,63));
1940 }
1941 else if(black_opening_count>0)
1942 {
1943 black_fade(63-zc_max(black_opening_count-3,0));
1944 }
1945 else black_fade(0);
1946 return; //no blitting from tmp_scr!
1947 }
1948
1949 90222 case bosCIRCLE:
1950 default:
1951 {
1952 90222 double new_w=(w/2)+abs(w/2-x);
1953 90222 double new_h=(h/2)+abs(h/2-y);
1954 90222 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1955 //circlefill(tmp_scr,x,y,a<<3,0);
1956 90222 circlefill(tmp_scr,x,y,r,0);
1957 90222 break;
1958 }
1959 }
1960
1961 99396 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1962 99396 }
1963
1964
1965 void black_fade(int32_t fadeamnt)
1966 {
1967 for(int32_t i=0; i < 0xEF; i++)
1968 {
1969 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1970 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1971 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1972 }
1973
1974 refreshpal = true;
1975 }
1976
1977 //----------------------------------------------------------------
1978
1979 38813628 bool item_disabled(int32_t item) //is this item disabled?
1980 {
1981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38813628 times.
38813628 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1982 }
1983
1984 7615632 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1985 {
1986
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7480384 times.
7615632 if(current_item(item_type, true) >=item)
1987 {
1988 135248 return true;
1989 }
1990
1991 7480384 return false;
1992 7615632 }
1993
1994 30661739 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1995 {
1996
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16010221 times.
✓ Branch 7 taken 5337683 times.
✓ Branch 8 taken 41747 times.
30661739 switch(item_type)
1997 {
1998 case itype_bomb:
1999 case itype_sbomb:
2000 {
2001 int32_t itemid = getItemID(itemsbuf, item_type, it);
2002
2003 if(itemid == -1)
2004 return false;
2005
2006 return (game->get_item(itemid));
2007 }
2008
2009 case itype_clock:
2010 {
2011 6051811 int32_t itemid = getItemID(itemsbuf, item_type, it);
2012
2013
2/4
✓ Branch 0 taken 6051811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
6051811 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2014 return (game->get_item(itemid));
2015 6051811 return Hero.getClock()?1:0;
2016 }
2017
2018 case itype_key:
2019 return (game->get_keys()>0);
2020
2021 case itype_magiccontainer:
2022 return (game->get_maxmagic()>=game->get_mp_per_block());
2023
2024 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liTRIFORCE)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liTRIFORCE);
2043
2044 default:
2045
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2046 {
2047 3220277 return (game->lvlitems[it]&liTRIFORCE);
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_map: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16010221 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liMAP)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liMAP)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16010221 times.
16010221 if(it>=0&&it<MAXLEVELS)
2078 {
2079 16010221 return (game->lvlitems[it]&liMAP)!=0;
2080 }
2081
2082 break;
2083 }
2084
2085 return 0;
2086 }
2087
2088 case itype_compass: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5337683 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liCOMPASS)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5337683 times.
✗ Branch 3 not taken.
5337683 if(it>=0&&it<MAXLEVELS)
2110 {
2111 5337683 return (game->lvlitems[it]&liCOMPASS)!=0;
2112 }
2113
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2120 {
2121
1/3
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
41747 switch(it)
2122 {
2123 case -2:
2124 {
2125 for(int32_t i=0; i<MAXLEVELS; i++)
2126 {
2127 if(game->lvlitems[i]&liBOSSKEY)
2128 {
2129 return true;
2130 }
2131 }
2132
2133 return false;
2134 }
2135
2136 case -1:
2137 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2138
2139 default:
2140
2/4
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41747 times.
41747 if(it>=0&&it<MAXLEVELS)
2141 {
2142 41747 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2143 }
2144 break;
2145 }
2146 return 0;
2147 }
2148
2149 default:
2150 //it=(1<<(it-1));
2151 /*if (item_type>=itype_max)
2152 {
2153 enter_sys_pal();
2154 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2155 exit_sys_pal();
2156
2157 return false;
2158 }*/
2159 int32_t itemid = getItemID(itemsbuf, item_type, it);
2160
2161 if(itemid == -1)
2162 return false;
2163
2164 return game->get_item(itemid);
2165 }
2166 30661739 }
2167
2168
2169 99990132 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2170 {
2171
9/9
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 51575644 times.
✓ Branch 2 taken 6051811 times.
✓ Branch 3 taken 6051811 times.
✓ Branch 4 taken 6051811 times.
✓ Branch 5 taken 6051811 times.
✓ Branch 6 taken 6051811 times.
✓ Branch 7 taken 6051811 times.
✓ Branch 8 taken 6051811 times.
99990132 switch(item_type)
2172 {
2173 case itype_clock:
2174 {
2175 6051811 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2176
2177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6051811 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6051811 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2178 return itemsbuf[maxid].fam_type;
2179
2180 6051811 return has_item(itype_clock,1) ? 1 : 0;
2181 }
2182
2183 case itype_key:
2184 6051811 return game->get_keys();
2185
2186 case itype_lkey:
2187 6051811 return game->lvlkeys[get_dlevel()];
2188
2189 case itype_magiccontainer:
2190 6051811 return game->get_maxmagic()/game->get_mp_per_block();
2191
2192 case itype_triforcepiece:
2193 {
2194 6051811 int32_t count=0;
2195
2196
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2197 {
2198 3098527232 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2199 3098527232 }
2200
2201 6051811 return count;
2202 }
2203
2204 case itype_map:
2205 {
2206 6051811 int32_t count=0;
2207
2208
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2209 {
2210 3098527232 count+=(game->lvlitems[i]&liMAP)?1:0;
2211 3098527232 }
2212
2213 6051811 return count;
2214 }
2215
2216 case itype_compass:
2217 {
2218 6051811 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 3098527232 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2223 3098527232 }
2224
2225 6051811 return count;
2226 }
2227
2228 case itype_bosskey:
2229 {
2230 6051811 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 3098527232 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2235 3098527232 }
2236
2237 6051811 return count;
2238 }
2239
2240 default:
2241 51575644 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2242
2243
2/2
✓ Branch 0 taken 9877306 times.
✓ Branch 1 taken 41698338 times.
51575644 if(maxid == -1)
2244 41698338 return 0;
2245
2246 9877306 return itemsbuf[maxid].fam_type;
2247 }
2248 99990132 }
2249
2250 92374500 int32_t current_item(int32_t item_type) //item currently being used
2251 {
2252 92374500 return current_item(item_type, true);
2253 }
2254
2255 46 std::map<int32_t, int32_t> itemcache;
2256
2257 // Not actually used by anything at the moment...
2258 void removeFromItemCache(int32_t itemclass)
2259 {
2260 itemcache.erase(itemclass);
2261 }
2262
2263 30026 void flushItemCache()
2264 {
2265 30026 itemcache.clear();
2266
2267 //also fix the active subscreen if items were deleted -DD
2268
1/2
✓ Branch 0 taken 30026 times.
✗ Branch 1 not taken.
30026 if(game != NULL)
2269 {
2270 30026 verifyBothWeapons();
2271 30026 load_Sitems();
2272 30026 }
2273 30026 }
2274
2275 // This is used often, so it should be as direct as possible.
2276 3372104039 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2277 {
2278
2/2
✓ Branch 0 taken 3296589042 times.
✓ Branch 1 taken 75514997 times.
3372104039 if(jinx_check)
2279 {
2280
4/4
✓ Branch 0 taken 47347658 times.
✓ Branch 1 taken 28167339 times.
✓ Branch 2 taken 39070031 times.
✓ Branch 3 taken 8277627 times.
75514997 if(!(HeroSwordClk() || HeroItemClk()))
2281 39070031 jinx_check = false; //not jinxed
2282 75514997 }
2283
4/4
✓ Branch 0 taken 3342722914 times.
✓ Branch 1 taken 29381125 times.
✓ Branch 2 taken 36112271 times.
✓ Branch 3 taken 3306610643 times.
3372104039 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2284 {
2285 3306610643 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2286
2287
2/2
✓ Branch 0 taken 3291280445 times.
✓ Branch 1 taken 15330198 times.
3306610643 if(res != itemcache.end())
2288 3291280445 return res->second;
2289 15330198 }
2290
2291 80823594 int32_t result = -1;
2292 80823594 int32_t highestlevel = -1;
2293
2294
2/2
✓ Branch 0 taken 20690840064 times.
✓ Branch 1 taken 80823594 times.
20771663658 for(int32_t i=0; i<MAXITEMS; i++)
2295 {
2296
5/6
✓ Branch 0 taken 1517290607 times.
✓ Branch 1 taken 19173549457 times.
✓ Branch 2 taken 21721499 times.
✓ Branch 3 taken 1495569108 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21721499 times.
20690840064 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2297 {
2298
4/4
✓ Branch 0 taken 5877485 times.
✓ Branch 1 taken 15844014 times.
✓ Branch 2 taken 1817058 times.
✓ Branch 3 taken 19904441 times.
21721499 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2299 {
2300 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2301
2/2
✓ Branch 0 taken 19904268 times.
✓ Branch 1 taken 173 times.
19904441 if(!checkmagiccost(i))
2302 {
2303
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 161 times.
173 if ( !get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2304 12 }
2305 19904280 }
2306
6/6
✓ Branch 0 taken 18413096 times.
✓ Branch 1 taken 3308242 times.
✓ Branch 2 taken 311736 times.
✓ Branch 3 taken 2996506 times.
✓ Branch 4 taken 1799132 times.
✓ Branch 5 taken 1509110 times.
21721338 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2307 {
2308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509110 times.
1509110 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2309 1509110 continue;
2310 }
2311
2312
2/2
✓ Branch 0 taken 278914 times.
✓ Branch 1 taken 19933314 times.
20212228 if(itemsbuf[i].fam_type >= highestlevel)
2313 {
2314 19933314 highestlevel = itemsbuf[i].fam_type;
2315 19933314 result=i;
2316 19933314 }
2317 20212228 }
2318 20689330793 }
2319
2320
2/2
✓ Branch 0 taken 36444966 times.
✓ Branch 1 taken 44378628 times.
80823594 if(!jinx_check) //Can't cache jinx_check results
2321 44378628 itemcache[itemtype] = result;
2322 80823594 return result;
2323 3372104039 }
2324
2325 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2326 3336103286 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2327 {
2328 3336103286 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2329
2/2
✓ Branch 0 taken 39514244 times.
✓ Branch 1 taken 3296589042 times.
3336103286 if(!jinx_check) //If not already a jinx-immune-only check...
2330 {
2331 //And the player IS jinxed...
2332
4/4
✓ Branch 0 taken 3268764680 times.
✓ Branch 1 taken 27824362 times.
✓ Branch 2 taken 8176391 times.
✓ Branch 3 taken 3260588289 times.
3296589042 if(HeroSwordClk() || HeroItemClk())
2333 {
2334 //Then do a jinx-immune-only check here
2335 36000753 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2336 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2337 //Should NOT need a compat rule, as this should always return -1 in old quests.
2338
2/2
✓ Branch 0 taken 1216689 times.
✓ Branch 1 taken 34784064 times.
36000753 if(ret2 > -1) return ret2;
2339 34784064 }
2340 3295372353 }
2341 3334886597 return ret;
2342 3336103286 }
2343 19237880 int32_t current_item_power(int32_t itemtype)
2344 {
2345 19237880 int32_t result = current_item_id(itemtype,true);
2346
2/2
✓ Branch 0 taken 13950304 times.
✓ Branch 1 taken 5287576 times.
19237880 return (result<0) ? 0 : itemsbuf[result].power;
2347 }
2348
2349 11 int32_t heart_container_id()
2350 {
2351
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2352 {
2353
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2354 {
2355 11 return i;
2356 }
2357 308 }
2358 return -1;
2359 11 }
2360
2361 6051811 int32_t item_tile_mod()
2362 {
2363 6051811 int32_t tile=0;
2364
2365
2/2
✓ Branch 0 taken 1204800 times.
✓ Branch 1 taken 4847011 times.
6051811 if(game->get_bombs())
2366 {
2367 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2368
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2369 4681842 tile+=itemsbuf[itemid].ltm;
2370 4847011 }
2371
2372
2/2
✓ Branch 0 taken 4537735 times.
✓ Branch 1 taken 1514076 times.
6051811 if(game->get_sbombs())
2373 {
2374 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2375
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2376 1512648 tile+=itemsbuf[itemid].ltm;
2377 1514076 }
2378
2379
2/2
✓ Branch 0 taken 5942111 times.
✓ Branch 1 taken 109700 times.
6051811 if(current_item(itype_clock))
2380 {
2381 109700 int32_t itemid =
2382
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2383 ? iClock
2384 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2385
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2386 109700 tile+=itemsbuf[itemid].ltm;
2387 109700 }
2388
2389
2/2
✓ Branch 0 taken 4671070 times.
✓ Branch 1 taken 1380741 times.
6051811 if(current_item(itype_key))
2390 {
2391 1380741 int32_t itemid =
2392
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2393 ? iKey
2394 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2395
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2396 1380741 tile+=itemsbuf[itemid].ltm;
2397 1380741 }
2398
2399
2/2
✓ Branch 0 taken 5784708 times.
✓ Branch 1 taken 267103 times.
6051811 if(current_item(itype_lkey))
2400 {
2401 267103 int32_t itemid =
2402
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2403 ? iLevelKey
2404 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2405
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2406 267103 tile+=itemsbuf[itemid].ltm;
2407 267103 }
2408
2409
2/2
✓ Branch 0 taken 1254994 times.
✓ Branch 1 taken 4796817 times.
6051811 if(current_item(itype_map))
2410 {
2411 4796817 int32_t itemid =
2412
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2413 ? iMap
2414 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2415
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2416 4796817 tile+=itemsbuf[itemid].ltm;
2417 4796817 }
2418
2419
2/2
✓ Branch 0 taken 1233112 times.
✓ Branch 1 taken 4818699 times.
6051811 if(current_item(itype_compass))
2420 {
2421 4818699 int32_t itemid =
2422
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2423 ? iCompass
2424 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2425
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2426 4818699 tile+=itemsbuf[itemid].ltm;
2427 4818699 }
2428
2429
2/2
✓ Branch 0 taken 3421266 times.
✓ Branch 1 taken 2630545 times.
6051811 if(current_item(itype_bosskey))
2430 {
2431 2630545 int32_t itemid =
2432
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2433 ? iBossKey
2434 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2435
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2436 2630545 tile+=itemsbuf[itemid].ltm;
2437 2630545 }
2438
2439
2/2
✓ Branch 0 taken 2917835 times.
✓ Branch 1 taken 3133976 times.
6051811 if(current_item(itype_magiccontainer))
2440 {
2441 3133976 int32_t itemid =
2442
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2443 ? iMagicC
2444 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2445
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2446 3132106 tile+=itemsbuf[itemid].ltm;
2447 3133976 }
2448
2449
2/2
✓ Branch 0 taken 1591177 times.
✓ Branch 1 taken 4460634 times.
6051811 if(current_item(itype_triforcepiece))
2450 {
2451 4460634 int32_t itemid =
2452
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2453 ? iTriforce
2454 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2455
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2456 4460634 tile+=itemsbuf[itemid].ltm;
2457 4460634 }
2458
2459
2/2
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 3098527232 times.
3104579043 for(int32_t i=0; i<itype_max; i++)
2460 {
2461
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56075776 times.
3098527232 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2462 {
2463
2/2
✓ Branch 0 taken 1095230 times.
✓ Branch 1 taken 54980546 times.
56075776 switch(i)
2464 {
2465 case itype_bomb:
2466 case itype_sbomb:
2467 case itype_clock:
2468 case itype_key:
2469 case itype_lkey:
2470 case itype_map:
2471 case itype_compass:
2472 case itype_bosskey:
2473 case itype_magiccontainer:
2474 case itype_triforcepiece:
2475 1095230 continue; //already handled
2476 }
2477 54980546 }
2478 3097432002 int32_t itemid = current_item_id(i,false);
2479
2/2
✓ Branch 0 taken 3091380191 times.
✓ Branch 1 taken 6051811 times.
3097432002 if(i == itype_shield)
2480 6051811 itemid = getCurrentShield(false);
2481
2482
4/4
✓ Branch 0 taken 80852133 times.
✓ Branch 1 taken 3016579869 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80751152 times.
3097432002 if(itemid < 0 || !checkbunny(itemid))
2483 3016680850 continue;
2484
2485 80751152 itemdata const& itm = itemsbuf[itemid];
2486
2487
2/2
✓ Branch 0 taken 75336675 times.
✓ Branch 1 taken 5414477 times.
80751152 switch(itm.family)
2488 {
2489 case itype_shield:
2490
1/2
✓ Branch 0 taken 5414477 times.
✗ Branch 1 not taken.
5414477 if(itm.flags & ITEM_FLAG9) //active shield
2491 {
2492 if(!usingActiveShield(itemid))
2493 {
2494 tile+=itm.misc6; //'Inactive PTM'
2495 continue;
2496 }
2497 }
2498 5414477 break;
2499 }
2500
2501 80751152 tile+=itm.ltm;
2502 80751152 }
2503
2504 6051811 return tile;
2505 }
2506
2507 6051811 int32_t bunny_tile_mod()
2508 {
2509
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6049941 times.
6051811 if(Hero.BunnyClock())
2510 {
2511 1870 return game->get_bunny_ltm();
2512 }
2513 6049941 return 0;
2514 6051811 }
2515
2516 // Hints are drawn on a separate layer to combo reveals.
2517 16332 void draw_lens_under(BITMAP *dest, bool layer)
2518 {
2519 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2520 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2521 //Lens flag 3: Don't show armos/chest/dive items
2522 //Lens flag 4: Show Raft Paths
2523 //Lens flag 5: Show Invisible Enemies
2524
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2525
2526 16332 int32_t strike_hint_table[11]=
2527 {
2528 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2529 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2530 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2531 };
2532
2533 // int32_t page = tmpscr->cpage;
2534 {
2535 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2536 // int32_t temptimer=0;
2537 16332 int32_t tempitem, tempweapon=0;
2538 16332 strike_hint=strike_hint_table[strike_hint_counter];
2539
2540
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2541 {
2542 492 strike_hint_timer=0;
2543 492 strike_hint_counter=((strike_hint_counter+1)%11);
2544 492 }
2545
2546 16332 ++strike_hint_timer;
2547
2548
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2549 {
2550 2874432 int32_t x = (i & 15) << 4;
2551 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2552 2874432 int32_t tempitemx=-16, tempitemy=-16;
2553 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2554
2555
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2556 {
2557 5748864 int32_t checkflag=0;
2558
2559
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2560 {
2561 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2562 2874432 }
2563 else
2564 {
2565 2874432 checkflag=tmpscr->sflag[i];
2566 }
2567
2568
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2569 {
2570
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2571 {
2572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2573 906 }
2574 else
2575 {
2576 192 checkflag = strike_hint;
2577 }
2578 1098 }
2579
2580
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2581 {
2582 case 0:
2583 case mfZELDA:
2584 case mfPUSHED:
2585 case mfENEMY0:
2586 case mfENEMY1:
2587 case mfENEMY2:
2588 case mfENEMY3:
2589 case mfENEMY4:
2590 case mfENEMY5:
2591 case mfENEMY6:
2592 case mfENEMY7:
2593 case mfENEMY8:
2594 case mfENEMY9:
2595 case mfSINGLE:
2596 case mfSINGLE16:
2597 case mfNOENEMY:
2598 case mfTRAP_H:
2599 case mfTRAP_V:
2600 case mfTRAP_4:
2601 case mfTRAP_LR:
2602 case mfTRAP_UD:
2603 case mfNOGROUNDENEMY:
2604 case mfNOBLOCKS:
2605 case mfSCRIPT1:
2606 case mfSCRIPT2:
2607 case mfSCRIPT3:
2608 case mfSCRIPT4:
2609 case mfSCRIPT5:
2610 case mfSCRIPT6:
2611 case mfSCRIPT7:
2612 case mfSCRIPT8:
2613 case mfSCRIPT9:
2614 case mfSCRIPT10:
2615 case mfSCRIPT11:
2616 case mfSCRIPT12:
2617 case mfSCRIPT13:
2618 case mfSCRIPT14:
2619 case mfSCRIPT15:
2620 case mfSCRIPT16:
2621 case mfSCRIPT17:
2622 case mfSCRIPT18:
2623 case mfSCRIPT19:
2624 case mfSCRIPT20:
2625 case mfPITHOLE:
2626 case mfPITFALLFLOOR:
2627 case mfLAVA:
2628 case mfICE:
2629 case mfICEDAMAGE:
2630 case mfDAMAGE1:
2631 case mfDAMAGE2:
2632 case mfDAMAGE4:
2633 case mfDAMAGE8:
2634 case mfDAMAGE16:
2635 case mfDAMAGE32:
2636 case mfFREEZEALL:
2637 case mfFREZEALLANSFFCS:
2638 case mfFREEZEFFCSOLY:
2639 case mfSCRITPTW1TRIG:
2640 case mfSCRITPTW2TRIG:
2641 case mfSCRITPTW3TRIG:
2642 case mfSCRITPTW4TRIG:
2643 case mfSCRITPTW5TRIG:
2644 case mfSCRITPTW6TRIG:
2645 case mfSCRITPTW7TRIG:
2646 case mfSCRITPTW8TRIG:
2647 case mfSCRITPTW9TRIG:
2648 case mfSCRITPTW10TRIG:
2649 case mfTROWEL:
2650 case mfTROWELNEXT:
2651 case mfTROWELSPECIALITEM:
2652 case mfSLASHPOT:
2653 case mfLIFTPOT:
2654 case mfLIFTORSLASH:
2655 case mfLIFTROCK:
2656 case mfLIFTROCKHEAVY:
2657 case mfDROPITEM:
2658 case mfSPECIALITEM:
2659 case mfDROPKEY:
2660 case mfDROPLKEY:
2661 case mfDROPCOMPASS:
2662 case mfDROPMAP:
2663 case mfDROPBOSSKEY:
2664 case mfSPAWNNPC:
2665 case mfSWITCHHOOK:
2666 case mfSIDEVIEWLADDER:
2667 case mfSIDEVIEWPLATFORM:
2668 case mfNOENEMYSPAWN:
2669 case mfENEMYALL:
2670 case mfNOMIRROR:
2671 case mfUNSAFEGROUND:
2672 case mf168:
2673 case mf169:
2674 case mf170:
2675 case mf171:
2676 case mf172:
2677 case mf173:
2678 case mf174:
2679 case mf175:
2680 case mf176:
2681 case mf177:
2682 case mf178:
2683 case mf179:
2684 case mf180:
2685 case mf181:
2686 case mf182:
2687 case mf183:
2688 case mf184:
2689 case mf185:
2690 case mf186:
2691 case mf187:
2692 case mf188:
2693 case mf189:
2694 case mf190:
2695 case mf191:
2696 case mf192:
2697 case mf193:
2698 case mf194:
2699 case mf195:
2700 case mf196:
2701 case mf197:
2702 case mf198:
2703 case mf199:
2704 case mf200:
2705 case mf201:
2706 case mf202:
2707 case mf203:
2708 case mf204:
2709 case mf205:
2710 case mf206:
2711 case mf207:
2712 case mf208:
2713 case mf209:
2714 case mf210:
2715 case mf211:
2716 case mf212:
2717 case mf213:
2718 case mf214:
2719 case mf215:
2720 case mf216:
2721 case mf217:
2722 case mf218:
2723 case mf219:
2724 case mf220:
2725 case mf221:
2726 case mf222:
2727 case mf223:
2728 case mf224:
2729 case mf225:
2730 case mf226:
2731 case mf227:
2732 case mf228:
2733 case mf229:
2734 case mf230:
2735 case mf231:
2736 case mf232:
2737 case mf233:
2738 case mf234:
2739 case mf235:
2740 case mf236:
2741 case mf237:
2742 case mf238:
2743 case mf239:
2744 case mf240:
2745 case mf241:
2746 case mf242:
2747 case mf243:
2748 case mf244:
2749 case mf245:
2750 case mf246:
2751 case mf247:
2752 case mf248:
2753 case mf249:
2754 case mf250:
2755 case mf251:
2756 case mf252:
2757 case mf253:
2758 case mf254:
2759 case mfEXTENDED:
2760 5706470 break;
2761
2762 case mfPUSHUD:
2763 case mfPUSHLR:
2764 case mfPUSH4:
2765 case mfPUSHU:
2766 case mfPUSHD:
2767 case mfPUSHL:
2768 case mfPUSHR:
2769 case mfPUSHUDNS:
2770 case mfPUSHLRNS:
2771 case mfPUSH4NS:
2772 case mfPUSHUNS:
2773 case mfPUSHDNS:
2774 case mfPUSHLNS:
2775 case mfPUSHRNS:
2776 case mfPUSHUDINS:
2777 case mfPUSHLRINS:
2778 case mfPUSH4INS:
2779 case mfPUSHUINS:
2780 case mfPUSHDINS:
2781 case mfPUSHLINS:
2782 case mfPUSHRINS:
2783
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2784
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2785 {
2786 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2787 }
2788
2789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2790
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2791 {
2792
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2793 {
2794
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2795 {
2796 case cPUSH_HEAVY:
2797 case cPUSH_HW:
2798 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2799 72 tempitemx=x, tempitemy=y;
2800
2801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2802 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2803
2804 72 break;
2805
2806 case cPUSH_HEAVY2:
2807 case cPUSH_HW2:
2808 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2809 63 tempitemx=x, tempitemy=y;
2810
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2812 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2813
2814 63 break;
2815 }
2816 1032 }
2817 2438 }
2818
2819 3148 break;
2820
2821 case mfWHISTLE:
2822
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2823 {
2824 tempitem=getItemID(itemsbuf,itype_whistle,1);
2825
2826 if(tempitem<0) break;
2827
2828 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2830 {
2831 tempitemx=x;
2832 tempitemy=y;
2833 }
2834
2835 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2836 }
2837
2838 2418 break;
2839
2840 //Why is this here?
2841 case mfFAIRY:
2842 case mfMAGICFAIRY:
2843 case mfALLFAIRY:
2844 if(hints)
2845 {
2846 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2847
2848 if(tempitem < 0) break;
2849
2850 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2851 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2852 {
2853 tempitemx=x;
2854 tempitemy=y;
2855 }
2856
2857 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2858 }
2859
2860 break;
2861
2862 case mfANYFIRE:
2863
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2864 {
2865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2866 252 }
2867 else
2868 {
2869 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2870
2871
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2872
2873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2874
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2875 {
2876 189 tempitemx=x;
2877 189 tempitemy=y;
2878 189 }
2879
2880 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2881 }
2882
2883 504 break;
2884
2885 case mfSTRONGFIRE:
2886 if(!hints)
2887 {
2888 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2889 }
2890 else
2891 {
2892 tempitem=getItemID(itemsbuf,itype_candle,2);
2893
2894 if(tempitem<0) break;
2895
2896 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2897 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2898 {
2899 tempitemx=x;
2900 tempitemy=y;
2901 }
2902
2903 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2904 }
2905
2906 break;
2907
2908 case mfMAGICFIRE:
2909 if(!hints)
2910 {
2911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2912 }
2913 else
2914 {
2915 tempitem=getItemID(itemsbuf,itype_wand,1);
2916
2917 if(tempitem<0) break;
2918
2919 tempweapon=wFire;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927 else
2928 {
2929 tempweaponx=x;
2930 tempweapony=y;
2931 }
2932
2933 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2934 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2935 }
2936
2937 break;
2938
2939 case mfDIVINEFIRE:
2940 if(!hints)
2941 {
2942 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2943 }
2944 else
2945 {
2946 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2947
2948 if(tempitem<0) break;
2949
2950 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2951 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2952 {
2953 tempitemx=x;
2954 tempitemy=y;
2955 }
2956
2957 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2958 }
2959
2960 break;
2961
2962 case mfARROW:
2963
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2964 {
2965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2966 732 }
2967 else
2968 {
2969 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2970
2971
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2972
2973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2974
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2975 {
2976 61 tempitemx=x;
2977 61 tempitemy=y;
2978 61 }
2979
2980 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2981 }
2982
2983 814 break;
2984
2985 case mfSARROW:
2986 if(!hints)
2987 {
2988 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2989 }
2990 else
2991 {
2992 tempitem=getItemID(itemsbuf,itype_arrow,2);
2993
2994 if(tempitem<0) break;
2995
2996 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2997 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2998 {
2999 tempitemx=x;
3000 tempitemy=y;
3001 }
3002
3003 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3004 }
3005
3006 break;
3007
3008 case mfGARROW:
3009 if(!hints)
3010 {
3011 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3012 }
3013 else
3014 {
3015 tempitem=getItemID(itemsbuf,itype_arrow,3);
3016
3017 if(tempitem<0) break;
3018
3019 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3020 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3021 {
3022 tempitemx=x;
3023 tempitemy=y;
3024 }
3025
3026 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3027 }
3028
3029 break;
3030
3031 case mfBOMB:
3032
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3033 {
3034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3035 16 }
3036 else
3037 {
3038 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3039 17 tempweapon = wLitBomb;
3040
3041 //if (tempitem<0) break;
3042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3043
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3044 {
3045 12 tempweaponx=x;
3046 12 tempweapony=y;
3047 12 }
3048
3049 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3050 }
3051
3052 33 break;
3053
3054 case mfSBOMB:
3055
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3056 {
3057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3058 48 }
3059 else
3060 {
3061 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3062 //if (tempitem<0) break;
3063 48 tempweapon = wLitSBomb;
3064
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3066
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3067 {
3068 36 tempweaponx=x;
3069 36 tempweapony=y;
3070 36 }
3071
3072 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3073 }
3074
3075 96 break;
3076
3077 case mfARMOS_SECRET:
3078
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3079 {
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3081 12 }
3082 24 break;
3083
3084 case mfBRANG:
3085
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3086 {
3087 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3088 }
3089 else
3090 {
3091 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3092
3093
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3094
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3096
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3097 {
3098 4 tempitemx=x;
3099 4 tempitemy=y;
3100 4 }
3101
3102 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3103 }
3104
3105 5 break;
3106
3107 case mfMBRANG:
3108 if(!hints)
3109 {
3110 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3111 }
3112 else
3113 {
3114 tempitem=getItemID(itemsbuf,itype_brang,2);
3115
3116 if(tempitem<0) break;
3117
3118 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3119 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3120 {
3121 tempitemx=x;
3122 tempitemy=y;
3123 }
3124
3125 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3126 }
3127
3128 break;
3129
3130 case mfFBRANG:
3131 if(!hints)
3132 {
3133 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3134 }
3135 else
3136 {
3137 tempitem=getItemID(itemsbuf,itype_brang,3);
3138
3139 if(tempitem<0) break;
3140
3141 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3142 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3143 {
3144 tempitemx=x;
3145 tempitemy=y;
3146 }
3147
3148 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3149 }
3150
3151 break;
3152
3153 case mfWANDMAGIC:
3154 if(!hints)
3155 {
3156 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3157 }
3158 else
3159 {
3160 tempitem=getItemID(itemsbuf,itype_wand,1);
3161
3162 if(tempitem<0) break;
3163
3164 tempweapon=itemsbuf[tempitem].wpn3;
3165
3166 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3167 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3168 {
3169 tempitemx=x;
3170 tempitemy=y;
3171 }
3172 else
3173 {
3174 tempweaponx=x;
3175 tempweapony=y;
3176 --lens_hint_weapon[wMagic][4];
3177
3178 if(lens_hint_weapon[wMagic][4]<-8)
3179 {
3180 lens_hint_weapon[wMagic][4]=8;
3181 }
3182 }
3183
3184 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3185 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3186 }
3187
3188 break;
3189
3190 case mfREFMAGIC:
3191
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3192 {
3193 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3194 }
3195 else
3196 {
3197 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3198
3199
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3200
3201 16 tempweapon=ewMagic;
3202
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3204
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3205 {
3206 13 tempitemx=x;
3207 13 tempitemy=y;
3208 13 }
3209 else
3210 {
3211 3 tempweaponx=x;
3212 3 tempweapony=y;
3213
3214
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3215 {
3216 1 --lens_hint_weapon[ewMagic][4];
3217 1 }
3218 else
3219 {
3220 2 ++lens_hint_weapon[ewMagic][4];
3221 }
3222
3223
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3224 {
3225 lens_hint_weapon[ewMagic][2]=up;
3226 }
3227
3228
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3229 {
3230 2 lens_hint_weapon[ewMagic][2]=down;
3231 2 }
3232 }
3233
3234 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3235 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3236 }
3237
3238 16 break;
3239
3240 case mfREFFIREBALL:
3241
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3242 {
3243 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3244 }
3245 else
3246 {
3247 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3248
3249
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3250
3251 16 tempweapon=ewFireball;
3252
3253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3254
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3255 {
3256 12 tempitemx=x;
3257 12 tempitemy=y;
3258 12 tempweaponx=x;
3259 12 tempweapony=y;
3260 12 ++lens_hint_weapon[ewFireball][3];
3261
3262
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3263 {
3264 1 lens_hint_weapon[ewFireball][3]=-8;
3265 1 lens_hint_weapon[ewFireball][4]=8;
3266 1 }
3267
3268
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3269 {
3270 8 ++lens_hint_weapon[ewFireball][4];
3271 8 }
3272 else
3273 {
3274 4 --lens_hint_weapon[ewFireball][4];
3275 }
3276 12 }
3277
3278 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3279 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3280 }
3281
3282 16 break;
3283
3284 case mfSWORD:
3285
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3286 {
3287 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3288 }
3289 else
3290 {
3291 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3292
3293
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3294
3295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 5 tempitemx=x;
3299 5 tempitemy=y;
3300 5 }
3301
3302 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3303 }
3304
3305 7 break;
3306
3307 case mfWSWORD:
3308 if(!hints)
3309 {
3310 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3311 }
3312 else
3313 {
3314 tempitem=getItemID(itemsbuf,itype_sword,2);
3315
3316 if(tempitem<0) break;
3317
3318 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3320 {
3321 tempitemx=x;
3322 tempitemy=y;
3323 }
3324
3325 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3326 }
3327
3328 break;
3329
3330 case mfMSWORD:
3331 if(!hints)
3332 {
3333 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3334 }
3335 else
3336 {
3337 tempitem=getItemID(itemsbuf,itype_sword,3);
3338
3339 if(tempitem<0) break;
3340
3341 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3342 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3343 {
3344 tempitemx=x;
3345 tempitemy=y;
3346 }
3347
3348 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3349 }
3350
3351 break;
3352
3353 case mfXSWORD:
3354 if(!hints)
3355 {
3356 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3357 }
3358 else
3359 {
3360 tempitem=getItemID(itemsbuf,itype_sword,4);
3361
3362 if(tempitem<0) break;
3363
3364 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3365 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3366 {
3367 tempitemx=x;
3368 tempitemy=y;
3369 }
3370
3371 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3372 }
3373
3374 break;
3375
3376 case mfSWORDBEAM:
3377
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3378 {
3379 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3380 }
3381 else
3382 {
3383 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3384
3385
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3386
3387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3388
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3389 {
3390 11 tempitemx=x;
3391 11 tempitemy=y;
3392 11 }
3393
3394 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3395 }
3396
3397 16 break;
3398
3399 case mfWSWORDBEAM:
3400 if(!hints)
3401 {
3402 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3403 }
3404 else
3405 {
3406 tempitem=getItemID(itemsbuf,itype_sword,2);
3407
3408 if(tempitem<0) break;
3409
3410 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3411 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3412 {
3413 tempitemx=x;
3414 tempitemy=y;
3415 }
3416
3417 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3418 }
3419
3420 break;
3421
3422 case mfMSWORDBEAM:
3423 if(!hints)
3424 {
3425 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3426 }
3427 else
3428 {
3429 tempitem=getItemID(itemsbuf,itype_sword,3);
3430
3431 if(tempitem<0) break;
3432
3433 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3434 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3435 {
3436 tempitemx=x;
3437 tempitemy=y;
3438 }
3439
3440 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3441 }
3442
3443 break;
3444
3445 case mfXSWORDBEAM:
3446 if(!hints)
3447 {
3448 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3449 }
3450 else
3451 {
3452 tempitem=getItemID(itemsbuf,itype_sword,4);
3453
3454 if(tempitem<0) break;
3455
3456 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3457 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3458 {
3459 tempitemx=x;
3460 tempitemy=y;
3461 }
3462
3463 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3464 }
3465
3466 break;
3467
3468 case mfHOOKSHOT:
3469
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3470 {
3471 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3472 }
3473 else
3474 {
3475 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3476
3477
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3478
3479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3480
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3481 {
3482 12 tempitemx=x;
3483 12 tempitemy=y;
3484 12 }
3485
3486 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3487 }
3488
3489 17 break;
3490
3491 case mfWAND:
3492
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3493 {
3494 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3495 }
3496 else
3497 {
3498 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3499
3500
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3501
3502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3503
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3504 {
3505 28 tempitemx=x;
3506 28 tempitemy=y;
3507 28 }
3508
3509 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3510 }
3511
3512 35 break;
3513
3514 case mfHAMMER:
3515
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3516 {
3517 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3518 }
3519 else
3520 {
3521 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3522
3523
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3524
3525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3526
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3527 {
3528 13 tempitemx=x;
3529 13 tempitemy=y;
3530 13 }
3531
3532 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3533 }
3534
3535 17 break;
3536
3537 case mfARMOS_ITEM:
3538 case mfDIVE_ITEM:
3539
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3540 {
3541 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3542 2064 }
3543 2064 break;
3544
3545 case 16:
3546 case 17:
3547 case 18:
3548 case 19:
3549 case 20:
3550 case 21:
3551 case 22:
3552 case 23:
3553 case 24:
3554 case 25:
3555 case 26:
3556 case 27:
3557 case 28:
3558 case 29:
3559 case 30:
3560 case 31:
3561
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3563 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3564
3565 3618 break;
3566 case mfSECRETSNEXT:
3567 if(!hints)
3568 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3569 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3570
3571 break;
3572
3573 case mfSTRIKE:
3574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3575 {
3576 906 goto special;
3577 }
3578 else
3579 {
3580 break;
3581 }
3582
3583 28640 default: goto special;
3584
3585 special:
3586
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3587 {
3588
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3589 {
3590 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3591 4913 }
3592 6549 }
3593
3594 29546 break;
3595 }
3596 5748864 }
3597 2874432 }
3598
3599
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3600 {
3601
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3602 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3603
3604
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3605 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3606
3607
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3608 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3609
3610
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3611 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3612
3613
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3614 {
3615 43 showbombeddoor(dest, 0);
3616 43 }
3617
3618
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3619 {
3620 39 showbombeddoor(dest, 1);
3621 39 }
3622
3623
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3624 {
3625 showbombeddoor(dest, 2);
3626 }
3627
3628
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3629 {
3630 37 showbombeddoor(dest, 3);
3631 37 }
3632 8166 }
3633
3634
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3635 {
3636
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3637 {
3638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3639 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3640 1123 }
3641 else
3642 {
3643
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3644 {
3645 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3646 48 int32_t tempitemx=-16;
3647 48 int32_t tempitemy=-16;
3648
3649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3650
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3651 {
3652 24 tempitemx=tmpscr->stairx;
3653 24 tempitemy=tmpscr->stairy+playing_field_offset;
3654 24 }
3655
3656 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3657 48 }
3658 }
3659 2034 }
3660 }
3661 16332 }
3662
3663 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3664
3665 7997 void draw_lens_over()
3666 {
3667 // Oh, what the heck.
3668 static BITMAP *lens_scr = NULL;
3669 static int32_t last_width = -1;
3670 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3671
3672 // Only redraw the circle if the size has changed
3673
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3674 {
3675
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3676 {
3677 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3678 5 }
3679
3680 5 clear_to_color(lens_scr, BLACK);
3681 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3682 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3683 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3684 5 last_width=width;
3685 5 }
3686
3687 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3688 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3689 7997 }
3690
3691 //----------------------------------------------------------------
3692
3693 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3694 {
3695 //recreating a big bitmap every frame is highly sluggish.
3696
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3697 31111 clear_to_color(wavebuf, BLACK);
3698 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3699
3700 int32_t ofs;
3701 // int32_t amplitude=8;
3702 // int32_t wavelength=4;
3703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3704
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3705 31111 int32_t amp2=168;
3706
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3707 31111 int32_t i=frame%amp2;
3708
3709
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3710 {
3711
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3712 {
3713 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3714 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3715 }
3716 else
3717 {
3718 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3719 }
3720
3721
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3722 {
3723
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3724 {
3725 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3726 1338021888 }
3727 5226648 }
3728 5226648 }
3729 31111 }
3730
3731 4848 void draw_fuzzy(int32_t fuzz)
3732 // draws from right half of scrollbuf to framebuf
3733 {
3734 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3735 byte *start, *si, *di;
3736
3737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3738 fuzz = 1;
3739
3740 4848 xstep = 128%fuzz;
3741
3742
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3743 3838 xstep = fuzz-xstep;
3744
3745 4848 ystep = 112%fuzz;
3746
3747
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3748 3434 ystep = fuzz-ystep;
3749
3750 4848 firsty = 1;
3751
3752
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3753 {
3754 174932 start = &(scrollbuf->line[y][256]);
3755
3756
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3757 {
3758 1085952 si = start;
3759 1085952 di = &(framebuf->line[y+dy][0]);
3760 1085952 i = xstep;
3761 1085952 firstx = 1;
3762
3763
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3764 {
3765 278003712 *(di++) = *si;
3766
3767
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3768 {
3769
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3770 42668864 si += fuzz;
3771 else
3772 {
3773 1085952 si += fuzz-xstep;
3774 1085952 firstx = 0;
3775 }
3776
3777 43754816 i = 0;
3778 43754816 }
3779 278003712 }
3780 1085952 }
3781
3782
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3783 170084 y += fuzz;
3784 else
3785 {
3786 4848 y += ystep;
3787 4848 ystep = fuzz;
3788 4848 firsty = 0;
3789 }
3790 }
3791 4848 }
3792
3793 9285079 void updatescr(bool allowwavy)
3794 {
3795
4/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 9285033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
9285079 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3796
4/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 9285033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
9285079 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3797
3798
2/2
✓ Branch 0 taken 9258314 times.
✓ Branch 1 taken 26765 times.
9285079 if(toogam)
3799 {
3800 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3801 26765 }
3802
3803
1/2
✓ Branch 0 taken 9285079 times.
✗ Branch 1 not taken.
9285079 if(Showpal)
3804 dump_pal(framebuf);
3805
3806
2/2
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
9285079 if(!Playing)
3807 301063 black_opening_count=0;
3808
3809
2/2
✓ Branch 0 taken 9211819 times.
✓ Branch 1 taken 73260 times.
9285079 if(black_opening_count<0) //shape is opening up
3810 {
3811 73260 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3812
3813
2/4
✓ Branch 0 taken 73260 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73260 times.
73260 if(Advance||(!Paused))
3814 {
3815 73260 ++black_opening_count;
3816 73260 }
3817 73260 }
3818
2/2
✓ Branch 0 taken 9185683 times.
✓ Branch 1 taken 26136 times.
9211819 else if(black_opening_count>0) //shape is closing
3819 {
3820 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3821
3822
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3823 {
3824 26136 --black_opening_count;
3825 26136 }
3826 26136 }
3827
3828
3/4
✓ Branch 0 taken 9187189 times.
✓ Branch 1 taken 97890 times.
✓ Branch 2 taken 9187189 times.
✗ Branch 3 not taken.
9285079 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3829 {
3830 black_opening_shape = bosCIRCLE;
3831 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3832 refreshTints();
3833 refreshpal=true;
3834 }
3835
3836
2/2
✓ Branch 0 taken 9030880 times.
✓ Branch 1 taken 254199 times.
9285079 if(refreshpal)
3837 {
3838 254199 refreshpal=false;
3839 254199 RAMpal[253] = _RGB(0,0,0);
3840 254199 RAMpal[254] = _RGB(63,63,63);
3841 254199 hw_palette = &RAMpal;
3842 254199 update_hw_pal = true;
3843
3844 254199 create_rgb_table(&rgb_table, RAMpal, NULL);
3845 254199 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3846 254199 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3847
3848
2/2
✓ Branch 0 taken 65074944 times.
✓ Branch 1 taken 254199 times.
65329143 for(int32_t q=0; q<PAL_SIZE; q++)
3849 {
3850 65074944 trans_table2.data[0][q] = q;
3851 65074944 trans_table2.data[q][q] = q;
3852 65074944 }
3853 254199 }
3854
3855 9285079 bool clearwavy = (wavy <= 0);
3856
3857
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277424 times.
9285079 if(wavy <= 0)
3858 {
3859 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3860 9277424 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3861 9277424 }
3862
3863 9285079 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3864
3865
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9253718 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285079 if(wavy && Playing && allowwavy)
3866 {
3867 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3868 31111 }
3869
3870
2/2
✓ Branch 0 taken 9277424 times.
✓ Branch 1 taken 7655 times.
9285079 if(clearwavy)
3871 9277424 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3872
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3873 7655 wavy--; // Wavy was set by a script. Decrement it.
3874
3875
5/6
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8724442 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9285079 if(Playing && msgpos && !screenscrolling)
3876 {
3877
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3878 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3880 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3881
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3882 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3883 259574 }
3884
3885 /*
3886 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3887 {
3888 BITMAP* subBmp = 0;
3889 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3890 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3891 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3892 destroy_bitmap(subBmp);
3893 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3894 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3895 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3896 }
3897 */
3898
3899
2/2
✓ Branch 0 taken 9244022 times.
✓ Branch 1 taken 41057 times.
9285079 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3900
3901
2/2
✓ Branch 0 taken 9248647 times.
✓ Branch 1 taken 36432 times.
9285079 if(nosubscr)
3902 {
3903 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3904 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3905 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3906 36432 }
3907
3908 //TODO: Optimize blit 'overcalls' -Gleeok
3909
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9248647 times.
9285079 BITMAP *source = nosubscr ? panorama : wavybuf;
3910 9285079 blit(source,framebuf,0,0,0,0,256,224);
3911
3912 9285079 update_hw_screen();
3913 9285079 }
3914
3915 //----------------------------------------------------------------
3916
3917 static PALETTE syspal;
3918 int32_t onGUISnapshot()
3919 {
3920 char buf[200];
3921 int32_t num=0;
3922 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3923 do
3924 {
3925 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3926 }
3927 while(num<99999 && exists(buf));
3928
3929 BITMAP *b = create_bitmap_ex(8,resx,resy);
3930
3931 if(b)
3932 {
3933 blit(screen,b,0,0,0,0,resx,resy);
3934 save_bitmap(buf,b,RAMpal);
3935 destroy_bitmap(b);
3936 }
3937
3938 return D_O_K;
3939 }
3940
3941 int32_t onNonGUISnapshot()
3942 {
3943 PALETTE temppal;
3944 get_palette(temppal);
3945 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3946
3947 char buf[200];
3948 int32_t num=0;
3949
3950 do
3951 {
3952 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3953 }
3954 while(num<99999 && exists(buf));
3955
3956 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3957
3958 return D_O_K;
3959 }
3960
3961 int32_t onSnapshot()
3962 {
3963 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3964 {
3965 onGUISnapshot();
3966 }
3967 else
3968 {
3969 onNonGUISnapshot();
3970 }
3971
3972 return D_O_K;
3973 }
3974
3975 int32_t onSaveMapPic()
3976 {
3977 int32_t mapres2 = 0;
3978 char buf[200];
3979 int32_t num=0;
3980 mapscr tmpscr_b[2];
3981 mapscr tmpscr_c[6];
3982 BITMAP* _screen_draw_buffer = NULL;
3983 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3984 set_clip_state(_screen_draw_buffer,1);
3985
3986 for(int32_t i=0; i<6; ++i)
3987 {
3988 tmpscr_c[i] = tmpscr2[i];
3989 tmpscr2[i].zero_memory();
3990
3991 if(i>=2)
3992 {
3993 continue;
3994 }
3995
3996 tmpscr_b[i] = tmpscr[i];
3997 tmpscr[i].zero_memory();
3998 }
3999
4000 do
4001 {
4002 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4003 }
4004 while(num<99999 && exists(buf));
4005
4006 BITMAP* mappic = NULL;
4007
4008
4009 bool done=false, redraw=true;
4010
4011 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4012
4013 if(!mappic)
4014 {
4015 enter_sys_pal();
4016 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4017 exit_sys_pal();
4018 return D_O_K;;
4019 }
4020
4021 // draw the map
4022 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4023
4024 for(int32_t y=0; y<8; y++)
4025 {
4026 for(int32_t x=0; x<16; x++)
4027 {
4028 if(!displayOnMap(x, y))
4029 {
4030 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4031 }
4032 else
4033 {
4034 int32_t s = (y<<4) + x;
4035 loadscr2(1,s,-1);
4036
4037 for(int32_t i=0; i<6; i++)
4038 {
4039 if(tmpscr[1].layermap[i]<=0)
4040 continue;
4041
4042 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4043 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4044 {
4045 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4046
4047 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4048 }
4049 }
4050
4051 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4052
4053 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4054
4055 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4056 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4061 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4062 {
4063 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4064 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4065 {
4066 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4067 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4068 }
4069 }
4070 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4071
4072 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4075 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4076 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4077 {
4078 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4080 }
4081 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4082 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4083
4084 }
4085
4086 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4087 }
4088 }
4089
4090 for(int32_t i=0; i<6; ++i)
4091 {
4092 tmpscr2[i]=tmpscr_c[i];
4093
4094 if(i>=2)
4095 {
4096 continue;
4097 }
4098
4099 tmpscr[i]=tmpscr_b[i];
4100 }
4101
4102 save_bitmap(buf,mappic,RAMpal);
4103 destroy_bitmap(mappic);
4104 destroy_bitmap(_screen_draw_buffer);
4105 return D_O_K;
4106 }
4107
4108 13 void f_Quit(int32_t type)
4109 {
4110
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4111 return;
4112
4113 13 bool from_menu = is_sys_pal;
4114
4115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4116 {
4117 13 music_pause();
4118 13 pause_all_sfx();
4119 13 sys_mouse();
4120 13 }
4121 13 enter_sys_pal();
4122 13 clear_keybuf();
4123
4124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_version_check(0, 10))
4125 13 replay_poll();
4126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4127 13 replay_peek_quit();
4128
4129
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4130 switch(type)
4131 {
4132 case qQUIT:
4133 onQuit();
4134 break;
4135
4136 case qRESET:
4137 onReset();
4138 break;
4139
4140 case qEXIT:
4141 onExit();
4142 break;
4143 }
4144
4145
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4146 {
4147 13 kill_sfx();
4148 13 music_stop();
4149 13 exit_sys_pal();
4150 13 update_hw_screen();
4151 13 }
4152 else
4153 {
4154 exit_sys_pal();
4155 if(!from_menu)
4156 {
4157 music_resume();
4158 resume_all_sfx();
4159 }
4160 }
4161
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4163 13 game_mouse();
4164 13 eat_buttons();
4165
4166 13 zc_readrawkey(KEY_ESC);
4167
4168 13 zc_readrawkey(KEY_ENTER);
4169 13 }
4170
4171 //----------------------------------------------------------------
4172
4173 int32_t onNoWalls()
4174 {
4175 cheats_enqueue(Cheat::Walls);
4176 return D_O_K;
4177 }
4178
4179 int32_t onIgnoreSideview()
4180 {
4181 cheats_enqueue(Cheat::IgnoreSideView);
4182 return D_O_K;
4183 }
4184
4185 9284954 int32_t input_idle(bool checkmouse)
4186 {
4187 static int32_t mx, my, mz, mb;
4188
4189
4/6
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✓ Branch 3 taken 6823686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461268 times.
11746222 if(keypressed() || zc_key_pressed() ||
4190
4/8
✓ Branch 0 taken 2461268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461268 times.
✗ Branch 7 not taken.
2461268 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4191 {
4192 6823686 idle_count = 0;
4193
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823686 times.
6823686 if(active_count < MAX_ACTIVE)
4195 {
4196 6823686 ++active_count;
4197 6823686 }
4198 6823686 }
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461268 times.
2461268 else if(idle_count < MAX_IDLE)
4200 {
4201 2461268 ++idle_count;
4202 2461268 active_count = 0;
4203 2461268 }
4204
4205 9284954 mx = mouse_x;
4206 9284954 my = mouse_y;
4207 9284954 mz = mouse_z;
4208 9284954 mb = mouse_b;
4209
4210 9284954 return idle_count;
4211 }
4212
4213 int32_t onGoFast()
4214 {
4215 cheats_enqueue(Cheat::Fast);
4216 return D_O_K;
4217 }
4218
4219 int32_t onKillCheat()
4220 {
4221 cheats_enqueue(Cheat::Kill);
4222 return D_O_K;
4223 }
4224
4225 int32_t onSecretsCheat()
4226 {
4227 cheats_enqueue(Cheat::TrigSecrets);
4228 return D_O_K;
4229 }
4230 int32_t onSecretsCheatPerm()
4231 {
4232 cheats_enqueue(Cheat::TrigSecretsPerm);
4233 return D_O_K;
4234 }
4235
4236 int32_t onShowLayer0()
4237 {
4238 show_layer_0 = !show_layer_0;
4239 return D_O_K;
4240 }
4241 int32_t onShowLayer1()
4242 {
4243 show_layer_1 = !show_layer_1;
4244 return D_O_K;
4245 }
4246 int32_t onShowLayer2()
4247 {
4248 show_layer_2 = !show_layer_2;
4249 return D_O_K;
4250 }
4251 int32_t onShowLayer3()
4252 {
4253 show_layer_3 = !show_layer_3;
4254 return D_O_K;
4255 }
4256 int32_t onShowLayer4()
4257 {
4258 show_layer_4 = !show_layer_4;
4259 return D_O_K;
4260 }
4261 int32_t onShowLayer5()
4262 {
4263 show_layer_5 = !show_layer_5;
4264 return D_O_K;
4265 }
4266 int32_t onShowLayer6()
4267 {
4268 show_layer_6 = !show_layer_6;
4269 return D_O_K;
4270 }
4271 int32_t onShowLayerO()
4272 {
4273 show_layer_over=!show_layer_over;
4274 return D_O_K;
4275 }
4276 int32_t onShowLayerP()
4277 {
4278 show_layer_push=!show_layer_push;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayerS()
4282 {
4283 show_sprites=!show_sprites;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayerF()
4287 {
4288 show_ffcs=!show_ffcs;
4289 return D_O_K;
4290 }
4291 int32_t onShowLayerW()
4292 {
4293 show_walkflags=!show_walkflags;
4294 if(show_walkflags)
4295 show_effectflags = false;
4296 return D_O_K;
4297 }
4298 int32_t onShowLayerE()
4299 {
4300 show_effectflags=!show_effectflags;
4301 if(show_effectflags)
4302 show_walkflags = false;
4303 return D_O_K;
4304 }
4305 int32_t onShowFFScripts()
4306 {
4307 show_ff_scripts=!show_ff_scripts;
4308 return D_O_K;
4309 }
4310 int32_t onShowHitboxes()
4311 {
4312 show_hitboxes=!show_hitboxes;
4313 return D_O_K;
4314 }
4315 int32_t onShowInfoOpacity()
4316 {
4317 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4318 zc_set_config("zc","debug_info_opacity",info_opacity);
4319 return D_O_K;
4320 }
4321
4322 int32_t onLightSwitch()
4323 {
4324 cheats_enqueue(Cheat::Light);
4325 return D_O_K;
4326 }
4327
4328 int32_t onGoTo();
4329 int32_t onGoToComplete();
4330
4331 9284954 void syskeys()
4332 {
4333 9284954 update_system_keys();
4334
4335 int32_t oldtitle_version;
4336
4337
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(close_button_quit)
4338 {
4339 close_button_quit=false;
4340 f_Quit(qEXIT);
4341 }
4342
4343 9284954 poll_joystick();
4344
4345
2/10
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9284954 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9284954 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4346 {
4347 oldtitle_version=title_version;
4348 System();
4349 }
4350
4351 9284954 mouse_down=gui_mouse_b();
4352
4353
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F1))
4354 {
4355 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4356 {
4357 halt=!halt;
4358 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4359 }
4360 else
4361 {
4362 Throttlefps=!Throttlefps;
4363 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4364 }
4365 }
4366
4367 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4368 /*
4369 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4370 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4371 */
4372
4373
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F2))
4374 {
4375 ShowFPS=!ShowFPS;
4376 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4377 }
4378
4379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4380
4381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F4) && Playing)
4382 {
4383 Paused=true;
4384 Advance=true;
4385 }
4386
4387
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F6)) onTryQuit();
4388
4389 #ifndef ALLEGRO_MACOSX
4390
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4391
4392
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4393 #else
4394 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4395
4396 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4397 #endif
4398
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9284954 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4399
4400
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (zc_read_system_key(KEY_F12))
4401 {
4402 onSnapshot();
4403 }
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(debug_enabled && zc_read_system_key(KEY_TAB))
4406 set_debug(!get_debug());
4407
4408
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(CheatModifierKeys())
4409 {
4410 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4411 {
4412 if(!bindable_cheat(c))
4413 continue;
4414 if(get_debug() || cheat >= cheat_lvl(c))
4415 {
4416 if(checkcheat(c))
4417 cheats_hit_bind(c);
4418 }
4419 }
4420 }
4421
4422
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(volkeys)
4423 {
4424 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4425
4426 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4427
4428 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4429
4430 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4431 }
4432
4433
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9284954 if(!get_debug() || !SystemKeys || replay_is_replaying())
4434 9284954 goto bottom;
4435
4436 if(zc_readkey(KEY_D))
4437 {
4438 details = !details;
4439 rectfill(screen,0,0,319,7,BLACK);
4440 rectfill(screen,0,8,31,239,BLACK);
4441 rectfill(screen,288,8,319,239,BLACK);
4442 rectfill(screen,32,232,287,239,BLACK);
4443 }
4444
4445 if(zc_readkey(KEY_P)) Paused=!Paused;
4446
4447 //if(zc_readkey(KEY_P)) centerHero();
4448 if(zc_readkey(KEY_A))
4449 {
4450 Paused=true;
4451 Advance=true;
4452 }
4453
4454 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4455 #ifndef ALLEGRO_MACOSX
4456 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4457
4458 if(zc_readkey(KEY_F7))
4459 {
4460 Matrix(ss_speed, ss_density, 0);
4461 game_pal();
4462 }
4463 #else
4464 // The reason these are different on Mac in the first place is that
4465 // the OS doesn't let us use F9 and F10...
4466 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4467
4468 if(zc_readkey(KEY_F9))
4469 {
4470 Matrix(ss_speed, ss_density, 0);
4471 game_pal();
4472 }
4473 #endif
4474 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4475 {
4476 //change containers
4477 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4478 {
4479 //magic containers
4480 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4481 {
4482 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4483 }
4484 else
4485 {
4486 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4487 }
4488 }
4489 else
4490 {
4491 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4492 {
4493 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4494 }
4495 else
4496 {
4497 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4498 }
4499 }
4500 }
4501
4502 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4503 {
4504 //change containers
4505 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4506 {
4507 //magic containers
4508 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4509 {
4510 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4511 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4512 //heart containers
4513 }
4514 else
4515 {
4516 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4517 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4518 }
4519 }
4520 else
4521 {
4522 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4523 {
4524 game->set_magic(zc_max(game->get_magic()-1,0));
4525 }
4526 else
4527 {
4528 game->set_life(zc_max(game->get_life()-1,0));
4529 }
4530 }
4531 }
4532
4533 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4534
4535 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4536
4537 verifyBothWeapons();
4538
4539 bottom:
4540
4541
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(input_idle(true) > after_time())
4542 {
4543 Matrix(ss_speed, ss_density, 0);
4544 game_pal();
4545 }
4546 9284954 }
4547
4548 708145 void checkQuitKeys()
4549 {
4550 #ifndef ALLEGRO_MACOSX
4551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708145 times.
708145 if(key[KEY_F9]) f_Quit(qRESET);
4552
4553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708145 times.
708145 if(key[KEY_F10]) f_Quit(qEXIT);
4554 #else
4555 if(key[KEY_F7]) f_Quit(qRESET);
4556
4557 if(key[KEY_F8]) f_Quit(qEXIT);
4558 #endif
4559 708145 }
4560
4561 9284954 bool CheatModifierKeys()
4562 {
4563 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4564 // to trigger cheats.
4565
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (replay_is_replaying())
4566 9284954 return false;
4567
4568 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4569 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4570 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4571 {
4572 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4573 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4574 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4575 {
4576 return true;
4577 }
4578 }
4579 return false;
4580 9284954 }
4581
4582 //99:05:54, for some reason?
4583 #define OLDMAXTIME 21405240
4584 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4585 #define MAXTIME 1944000000
4586
4587 9285079 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4588 {
4589
2/2
✓ Branch 0 taken 9164956 times.
✓ Branch 1 taken 120123 times.
9285079 if(zcmusic!=NULL)
4590 {
4591 120123 zcmusic_poll();
4592 120123 }
4593
4594 9285079 updatescr(allowwavy);
4595
4596 9285079 Advance=false;
4597
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285079 times.
9285079 while(Paused && !Advance && !Quit)
4598 {
4599 // have to call this, otherwise we'll get an infinite loop
4600 syskeys();
4601 if(allowF6Script)
4602 {
4603 FFCore.runF6Engine();
4604 }
4605 throttleFPS();
4606
4607 #ifdef _WIN32
4608
4609 if(use_dwm_flush)
4610 {
4611 do_DwmFlush();
4612 }
4613
4614 #endif
4615
4616 // to keep music playing
4617 if(zcmusic!=NULL)
4618 {
4619 zcmusic_poll();
4620 }
4621
4622 update_hw_screen();
4623 }
4624
4625
2/2
✓ Branch 0 taken 9284967 times.
✓ Branch 1 taken 112 times.
9285079 if(Quit)
4626 112 return;
4627
4628
3/4
✓ Branch 0 taken 8984007 times.
✓ Branch 1 taken 300960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984007 times.
9284967 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4629 8984007 game->change_time(1);
4630
4631 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4632
4633 9284967 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4634
2/2
✓ Branch 0 taken 18170 times.
✓ Branch 1 taken 9266797 times.
9284967 if (replay_version_check(0, 16))
4635 9266797 should_reset_down_state = replay_version_check(11, 16);
4636
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2335287 times.
9284967 if (should_reset_down_state)
4637 {
4638
2/2
✓ Branch 0 taken 42035166 times.
✓ Branch 1 taken 2335287 times.
44370453 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4639 42035166 down_control_states[i] = raw_control_state[i];
4640 2335287 }
4641
4642
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284972 times.
9284967 if (replay_is_active())
4643 {
4644
2/2
✓ Branch 0 taken 1270468 times.
✓ Branch 1 taken 8014504 times.
9284972 if (replay_version_check(3))
4645 8014504 replay_poll();
4646
4647
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2338856 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9284972 if (replay_version_check(11) || replay_version_check(6, 8))
4648 2439391 replay_peek_input();
4649 9284954 }
4650
4651 9284967 load_control_called_this_frame = false;
4652
4653 9284967 poll_keyboard();
4654 9284967 update_keys();
4655
4656 9284967 ++frame;
4657
4658
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4659 9284954 replay_do_cheats();
4660 9284967 syskeys();
4661
4662 // The mouse variables can change from the mouse thread at anytime during a frame,
4663 // so save the result at the start so that replaying is consistent.
4664 9284967 script_mouse_x = gui_mouse_x();
4665 9284967 script_mouse_y = gui_mouse_y();
4666 9284967 script_mouse_z = mouse_z;
4667 9284967 script_mouse_b = mouse_b;
4668
4669 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4670 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4671 // approach here means it doesn't matter which call adds the cheat.
4672 9284967 cheats_execute_queued();
4673
4674
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4675 9284954 replay_peek_quit();
4676
2/2
✓ Branch 0 taken 9284954 times.
✓ Branch 1 taken 13 times.
9284967 if (GameFlags & GAMEFLAG_TRYQUIT)
4677 13 replay_step_quit(0);
4678
2/2
✓ Branch 0 taken 2933 times.
✓ Branch 1 taken 9282034 times.
9284967 if(allowF6Script)
4679 9282034 FFCore.runF6Engine();
4680
2/2
✓ Branch 0 taken 9284667 times.
✓ Branch 1 taken 300 times.
9284967 if (Quit)
4681 300 replay_step_quit(Quit);
4682 // Someday... maybe install a Turbo button here?
4683 9284967 throttleFPS();
4684
4685 #ifdef _WIN32
4686
4687 if(use_dwm_flush)
4688 {
4689 do_DwmFlush();
4690 }
4691
4692 #endif
4693
4694 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4695
2/2
✓ Branch 0 taken 68757 times.
✓ Branch 1 taken 9216210 times.
9284967 if(sfxcleanup)
4696 9216210 sfx_cleanup();
4697
4698 9284967 jit_poll();
4699 9285079 }
4700
4701 101 void zapout()
4702 {
4703 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4704 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4705
4706 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4707 101 script_drawing_commands.Clear();
4708
4709 // zap out
4710
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4711 {
4712 2424 draw_fuzzy(i);
4713 2424 advanceframe(true);
4714
4715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4716 {
4717 break;
4718 }
4719 2424 }
4720 101 }
4721
4722 101 void zapin()
4723 {
4724 101 FFCore.warpScriptCheck();
4725 101 draw_screen(tmpscr);
4726 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4727 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4728 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4729
4730 // zap out
4731 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4732
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4733 {
4734 2424 draw_fuzzy(i);
4735 2424 advanceframe(true);
4736
4737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4738 {
4739 break;
4740 }
4741 2424 }
4742 101 }
4743
4744
4745 65 void wavyout(bool showhero)
4746 {
4747 65 draw_screen(tmpscr, showhero);
4748 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4749
4750 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4751 65 clear_to_color(wavebuf,0);
4752 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4753
4754 static PALETTE wavepal;
4755
4756 int32_t ofs;
4757 65 int32_t amplitude=8;
4758
4759 65 int32_t wavelength=4;
4760 65 double palpos=0, palstep=4, palstop=126;
4761
4762 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4763
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4764 {
4765
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4766 {
4767 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4768 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4769 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4770 698880 }
4771
4772 2730 palpos+=palstep;
4773
4774
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4775 {
4776 2730 hw_palette = &wavepal;
4777 2730 update_hw_pal = true;
4778 2730 }
4779 else
4780 {
4781 hw_palette = &RAMpal;
4782 update_hw_pal = true;
4783 }
4784
4785
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4786 {
4787
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4788 {
4789 117411840 ofs=0;
4790
4791
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4792 {
4793 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4794 28654080 }
4795
4796 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4797 117411840 }
4798 458640 }
4799
4800 2730 advanceframe(true);
4801
4802 // animate_combos();
4803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4804 break;
4805 2730 }
4806
4807 65 destroy_bitmap(wavebuf);
4808 65 }
4809
4810 65 void wavyin()
4811 {
4812 65 draw_screen(tmpscr);
4813 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4814
4815 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4816 65 clear_to_color(wavebuf,0);
4817 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4818
4819 static PALETTE wavepal;
4820
4821 //Breaks dark rooms.
4822 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4823 /*
4824 loadfullpal();
4825 loadlvlpal(DMaps[currdmap].color);
4826 ringcolor(false);
4827 */
4828 65 refreshpal=false;
4829 int32_t ofs;
4830 65 int32_t amplitude=8;
4831 65 int32_t wavelength=4;
4832 65 double palpos=168, palstep=4, palstop=126;
4833
4834 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4835
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4836 {
4837
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4838 {
4839 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4840 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4841 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4842 698880 }
4843
4844 2730 palpos-=palstep;
4845
4846
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4847 {
4848 2730 hw_palette = &wavepal;
4849 2730 update_hw_pal = true;
4850 2730 }
4851 else
4852 {
4853 hw_palette = &RAMpal;
4854 update_hw_pal = true;
4855 }
4856
4857
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4858 {
4859
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4860 {
4861 117411840 ofs=0;
4862
4863
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4864 {
4865 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4866 29352960 }
4867
4868 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4869 117411840 }
4870 458640 }
4871
4872 2730 advanceframe(true);
4873 // animate_combos();
4874
4875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4876 break;
4877 2730 }
4878
4879 65 destroy_bitmap(wavebuf);
4880 65 }
4881
4882 2168 void blackscr(int32_t fcnt,bool showsubscr)
4883 {
4884 2168 reset_pal_cycling();
4885 2168 script_drawing_commands.Clear();
4886
4887 2168 FFCore.warpScriptCheck();
4888 2168 bool showtime = game->should_show_time();
4889
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4890 {
4891 64970 clear_bitmap(framebuf);
4892
4893
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4894 {
4895 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4896
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4897 {
4898 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4899 750 }
4900 39890 }
4901
4902 64970 advanceframe(true);
4903
4904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4905 break;
4906
4907 64970 --fcnt;
4908 }
4909 2168 }
4910
4911 1011 void openscreen(int32_t shape)
4912 {
4913 1011 reset_pal_cycling();
4914 1011 black_opening_count=0;
4915
4916
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1011 if(COOLSCROLL || shape>-1)
4917 {
4918 911 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4919 911 return;
4920 }
4921 else
4922 {
4923 100 Hero.setDontDraw(true);
4924 100 show_subscreen_dmap_dots=false;
4925 100 show_subscreen_numbers=false;
4926 // show_subscreen_items=false;
4927 100 show_subscreen_life=false;
4928 }
4929
4930 100 int32_t x=128;
4931
4932 100 FFCore.warpScriptCheck();
4933
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4934 {
4935 8000 draw_screen(tmpscr);
4936 //? draw_screen already draws the subscreen -DD
4937 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4938 8000 x=128-(((i*128/80)/8)*8);
4939
4940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4941 {
4942 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4943 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4944 8000 }
4945
4946 8000 advanceframe(true);
4947
4948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
4949 {
4950 break;
4951 }
4952 8000 }
4953
4954 100 Hero.setDontDraw(false);
4955 100 show_subscreen_items=true;
4956 100 show_subscreen_dmap_dots=true;
4957 1011 }
4958
4959 void closescreen(int32_t shape)
4960 {
4961 reset_pal_cycling();
4962 black_opening_count=0;
4963
4964 if(COOLSCROLL || shape>-1)
4965 {
4966 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4967 return;
4968 }
4969 else
4970 {
4971 Hero.setDontDraw(true);
4972 show_subscreen_dmap_dots=false;
4973 show_subscreen_numbers=false;
4974 // show_subscreen_items=false;
4975 show_subscreen_life=false;
4976 }
4977
4978 int32_t x=128;
4979
4980 FFCore.warpScriptCheck();
4981 for(int32_t i=79; i>=0; --i)
4982 {
4983 draw_screen(tmpscr);
4984 //? draw_screen already draws the subscreen -DD
4985 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4986 x=128-(((i*128/80)/8)*8);
4987
4988 if(x>0)
4989 {
4990 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4991 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4992 }
4993
4994 advanceframe(true);
4995
4996 if(Quit)
4997 {
4998 break;
4999 }
5000 }
5001
5002 Hero.setDontDraw(false);
5003 show_subscreen_items=true;
5004 show_subscreen_dmap_dots=true;
5005 }
5006
5007 179 int32_t TriforceCount()
5008 {
5009 179 int32_t c=0;
5010
5011
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5012
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5013 1044 ++c;
5014
5015 179 return c;
5016 }
5017
5018 int32_t onCustomGame()
5019 {
5020 int32_t file = getsaveslot();
5021
5022 if(file < 0)
5023 return D_O_K;
5024
5025 bool ret = (custom_game(file)!=0);
5026 return ret ? D_CLOSE : D_O_K;
5027 }
5028
5029 int32_t onContinue()
5030 {
5031 return D_CLOSE;
5032 }
5033
5034 int32_t onEsc() // Unused?? -L
5035 {
5036 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5037 }
5038
5039 int32_t onVsync()
5040 {
5041 Throttlefps = !Throttlefps;
5042 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5043 return D_O_K;
5044 }
5045
5046 int32_t onWinPosSave()
5047 {
5048 SaveWinPos = !SaveWinPos;
5049 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5050 return D_O_K;
5051 }
5052 int32_t onIntegerScaling()
5053 {
5054 scaleForceInteger = !scaleForceInteger;
5055 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5056 return D_O_K;
5057 }
5058 int32_t onStretchGame()
5059 {
5060 stretchGame = !stretchGame;
5061 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5062 return D_O_K;
5063 }
5064
5065 int32_t onClickToFreeze()
5066 {
5067 ClickToFreeze = !ClickToFreeze;
5068 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5069 return D_O_K;
5070 }
5071
5072 int32_t OnSaveZCConfig()
5073 {
5074 if(jwin_alert3(
5075 "Save Configuration",
5076 "Are you sure that you wish to save your present configuration settings?",
5077 "This will overwrite your prior settings!",
5078 NULL,
5079 "&Yes",
5080 "&No",
5081 NULL,
5082 'y',
5083 'n',
5084 0,
5085 get_zc_font(font_lfont)) == 1)
5086 {
5087 save_game_configs();
5088 return D_O_K;
5089 }
5090 else return D_O_K;
5091 }
5092
5093 int32_t OnnClearQuestDir()
5094 {
5095 if(jwin_alert3(
5096 "Clear Current Directory Cache",
5097 "Are you sure that you wish to clear the current cached directory?",
5098 "This will default the current directory to the ROOT for this instance of ZC Player!",
5099 NULL,
5100 "&Yes",
5101 "&No",
5102 NULL,
5103 'y',
5104 'n',
5105 0,
5106 get_zc_font(font_lfont)) == 1)
5107 {
5108 zc_set_config("zeldadx","win_qst_dir","");
5109 flush_config_file();
5110 strcpy(qstdir,"");
5111 #ifdef __EMSCRIPTEN__
5112 em_sync_fs();
5113 #endif
5114 return D_O_K;
5115 }
5116 else return D_O_K;
5117 }
5118
5119
5120 int32_t onConsoleZASM()
5121 {
5122 if ( !zasm_debugger )
5123 {
5124 AlertDialog("WARNING: ZASM Debugger",
5125 "Enabling this will open the ZASM Debugger Console"
5126 "\nThis will likely grind ZC to a halt with lag."
5127 "\nTo make any use of this, it is suggested that you read"
5128 "\nthe documentation for 'void Breakpoint(char[] string);'"
5129 " in 'ZScript_Additions.txt'"
5130 "\nThis is not recommended for normal users,"
5131 " and is only intended for ZC developers,"
5132 "\nor quest developers coding directly in ZASM"
5133 "\nAre you sure that you wish to open the ZASM Debugger?",
5134 [&](bool ret,bool)
5135 {
5136 if(ret)
5137 {
5138 FFCore.ZASMPrint(true);
5139 }
5140 }).show();
5141 return D_O_K;
5142 }
5143 else
5144 {
5145 FFCore.ZASMPrint(false);
5146 return D_O_K;
5147 }
5148 }
5149
5150
5151 int32_t onConsoleZScript()
5152 {
5153 if ( !zscript_debugger )
5154 {
5155 AlertDialog("ZScript Debugger",
5156 "Enabling this will open the ZScript Debugger Console"
5157 "\nThis will display any messages logged by scripts,"
5158 " including script errors."
5159 "\nAre you sure that you wish to open the ZScript Debugger?",
5160 [&](bool ret,bool)
5161 {
5162 if(ret)
5163 {
5164 FFCore.ZScriptConsole(true);
5165 }
5166 }).show();
5167 return D_O_K;
5168 }
5169 else
5170 {
5171 FFCore.ZScriptConsole(false);
5172 return D_O_K;
5173 }
5174 }
5175
5176 int32_t onClrConsoleOnReload()
5177 {
5178 clearConsoleOnReload = !clearConsoleOnReload;
5179 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5180 return D_O_K;
5181 }
5182 int32_t onClrConsoleOnLoad()
5183 {
5184 clearConsoleOnLoad = !clearConsoleOnLoad;
5185 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5186 return D_O_K;
5187 }
5188
5189
5190 int32_t onFrameSkip()
5191 {
5192 FrameSkip = !FrameSkip;
5193 return D_O_K;
5194 }
5195
5196 int32_t onSaveDragResize()
5197 {
5198 SaveDragResize = !SaveDragResize;
5199 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5200 return D_O_K;
5201 }
5202
5203 int32_t onDragAspect()
5204 {
5205 DragAspect = !DragAspect;
5206 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5207 return D_O_K;
5208 }
5209
5210 int32_t onTransLayers()
5211 {
5212 TransLayers = !TransLayers;
5213 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5214 return D_O_K;
5215 }
5216
5217 int32_t onNESquit()
5218 {
5219 NESquit = !NESquit;
5220 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5221 return D_O_K;
5222 }
5223
5224 int32_t onVolKeys()
5225 {
5226 volkeys = !volkeys;
5227 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5228 return D_O_K;
5229 }
5230
5231 int32_t onShowFPS()
5232 {
5233 ShowFPS = !ShowFPS;
5234 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5235 return D_O_K;
5236 }
5237
5238 1095624572 bool is_Fkey(int32_t k)
5239 {
5240
2/2
✓ Branch 0 taken 111419448 times.
✓ Branch 1 taken 984205124 times.
1095624572 switch(k)
5241 {
5242 case KEY_F1:
5243 case KEY_F2:
5244 case KEY_F3:
5245 case KEY_F4:
5246 case KEY_F5:
5247 case KEY_F6:
5248 case KEY_F7:
5249 case KEY_F8:
5250 case KEY_F9:
5251 case KEY_F10:
5252 case KEY_F11:
5253 case KEY_F12:
5254 111419448 return true;
5255 }
5256
5257 984205124 return false;
5258 1095624572 }
5259
5260 void kb_getkey(DIALOG *d);
5261
5262 //Used by all keyboard key settings dialogues.
5263 void kb_clearjoystick(DIALOG *d)
5264 {
5265 d->flags|=D_SELECTED;
5266
5267 jwin_button_proc(MSG_DRAW,d,0);
5268 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5269 // text_mode(vc(11));
5270 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5271 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5272
5273 update_hw_screen(true);
5274
5275 clear_keybuf();
5276 int32_t k = next_press_key();
5277 clear_keybuf();
5278
5279 //shnarf
5280 //47=f1
5281 //59=esc
5282 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5283 // *((int32_t*)d->dp3) = k;
5284 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5285
5286
5287 d->flags&=~D_SELECTED;
5288 }
5289
5290 //Clears key to 0.
5291 //Used by all keyboard key settings dialogues.
5292 void kb_clearkey(DIALOG *d);
5293
5294 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5295 {
5296 switch(msg)
5297 {
5298 case MSG_KEY:
5299 case MSG_CLICK:
5300
5301 kb_clearjoystick(d);
5302
5303 while(gui_mouse_b())
5304 {
5305 clear_keybuf();
5306 rest(1);
5307 }
5308
5309 return D_REDRAW;
5310 }
5311
5312 return jwin_button_proc(msg,d,c);
5313 }
5314
5315 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5316 //Only used in keyboard settings dialogues to clear keys.
5317 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5318
5319 void j_getbtn(DIALOG *d)
5320 {
5321 d->flags|=D_SELECTED;
5322 jwin_button_proc(MSG_DRAW,d,0);
5323 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5324 // text_mode(vc(11));
5325 int32_t y = screen->h/2 - 12;
5326 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5327 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5328 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5329
5330 update_hw_screen(true);
5331
5332 int32_t b = next_press_btn();
5333
5334 if(b>=0)
5335 *((int32_t*)d->dp3) = b;
5336
5337 d->flags&=~D_SELECTED;
5338
5339 if (player)
5340 player->joy_on = TRUE;
5341 }
5342
5343 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5344 {
5345 switch(msg)
5346 {
5347 case MSG_KEY:
5348 case MSG_CLICK:
5349
5350 j_getbtn(d);
5351
5352 while(gui_mouse_b()) {
5353 rest(1);
5354 clear_keybuf();
5355 }
5356
5357 return D_REDRAW;
5358 }
5359
5360 return jwin_button_proc(msg,d,c);
5361 }
5362
5363 //shnarf
5364 extern const char *key_str[];
5365 std::string get_keystr(int key);
5366
5367 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5368 //extern int32_t zcmusic_bufsz;
5369
5370 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5371 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5372
5373 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5374 {
5375 //these are here to bypass compiler warnings about unused arguments
5376 c=c;
5377
5378 if(msg==MSG_DRAW)
5379 {
5380 switch(d->w)
5381 {
5382 case 0:
5383 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5384 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5385 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5386 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5387 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5388 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5389 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5390 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5391 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5392 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5393 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5394 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5395 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5396 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5397 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5398 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5399 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5400 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5401 break;
5402
5403 case 1:
5404 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5405 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5406 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5407 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5408 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5409 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5410 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5411 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5412 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5413 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5414 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5415 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5416 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5417 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5418 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5419 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5420 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5421 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5422 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5423 break;
5424
5425 case 2:
5426 sprintf(str_a," %3d",midi_volume);
5427 sprintf(str_b," %3d",digi_volume);
5428 sprintf(str_l," %3d",emusic_volume);
5429 sprintf(str_m," %3dKB",zcmusic_bufsz);
5430 sprintf(str_r," %3d",sfx_volume);
5431 strcpy(str_s,pan_str[pan_style]);
5432 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5433 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5434 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5435 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5436 break;
5437 }
5438 }
5439
5440 return D_O_K;
5441 }
5442
5443 int32_t set_vol(void *dp3, int32_t d2)
5444 {
5445 switch(((int32_t*)dp3)[0])
5446 {
5447 case 0:
5448 midi_volume = zc_min(d2<<3,255);
5449 break;
5450
5451 case 1:
5452 digi_volume = zc_min(d2<<3,255);
5453 break;
5454
5455 case 2:
5456 emusic_volume = zc_min(d2<<3,255);
5457 break;
5458
5459 case 3:
5460 sfx_volume = zc_min(d2<<3,255);
5461 break;
5462 }
5463
5464 // text_mode(vc(11));
5465 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5466 return D_O_K;
5467 }
5468
5469 int32_t set_pan(void *dp3, int32_t d2)
5470 {
5471 pan_style = vbound(d2,0,3);
5472 // text_mode(vc(11));
5473 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5474 return D_O_K;
5475 }
5476
5477 int32_t set_buf(void *dp3, int32_t d2)
5478 {
5479 // text_mode(vc(11));
5480 zcmusic_bufsz = d2 + 1;
5481 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5482 return D_O_K;
5483 }
5484
5485 static int32_t gamepad_btn_list[] =
5486 {
5487 6,
5488 7,8,9,10,11,12,13,14,15,16,17,
5489 18,19,20,21,22,23,24,25,26,27,28,
5490 29,30,31,32,33,34,35,36,37,38,39,
5491 -1
5492 };
5493
5494 static int32_t gamepad_dirs_list[] =
5495 {
5496 40,41,42,43,
5497 44,45,46,47,
5498 48,49,50,51,
5499 52,53,54,55,
5500 56,
5501 -1
5502 };
5503
5504 static TABPANEL gamepad_tabs[] =
5505 {
5506 // (text)
5507 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5508 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5509 { NULL, 0, NULL, 0, NULL }
5510 };
5511
5512 static DIALOG gamepad_dlg[] =
5513 {
5514 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5515 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5516 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5517 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5518 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5519 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5520 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5521 // 6
5522 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5523 // 7
5524 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5525 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5526 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5527 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5528 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5529 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5530 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5531 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5532 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5533 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5534 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5535 // 18
5536 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5537 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5538 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5539 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5540 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5541 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5542 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5543 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5544 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5545 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5546 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5547 // 29
5548 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5549 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5550 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5551 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5552 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5553 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5554 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5555 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5556 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5557 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5558 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5559 // 40
5560 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5561 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5562 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5563 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5564 // 44
5565 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5566 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5567 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5568 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5569 // 48
5570 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5571 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5572 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5573 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5574 // 52
5575 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5576 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5577 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5578 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5579 // 56
5580 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5581 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5582 };
5583
5584 static int32_t keyboard_keys_list[] =
5585 {
5586 6,7,8,9,10,
5587 11,12,13,14,15,16,17,18,19,20,
5588 21,22,23,24,25,26,27,28,29,30,
5589 31,32,33,34,35,36,37,38,39,40,
5590 -1
5591 };
5592
5593 static int32_t keyboard_dirs_list[] =
5594 {
5595 41,42,43,44,
5596 45,46,47,48,
5597 49,50,51,52,
5598 53,54,55,56,
5599 -1
5600 };
5601
5602 static int32_t keyboard_mods_list[] =
5603 {
5604 57,58,59,60,
5605 61,62,63,64,
5606 65,66,67,68,
5607 69,70,71,72,
5608 -1
5609 };
5610
5611 static TABPANEL keyboard_control_tabs[] =
5612 {
5613 // (text)
5614 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5615 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5616 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5617 { NULL, 0, NULL, 0, NULL }
5618 };
5619
5620 static DIALOG keyboard_control_dlg[] =
5621 {
5622 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5623 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5624 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5625 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5626 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5627 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5628 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5629 // Keys
5630 // 6
5631 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5632 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5633 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5634 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5635 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5636 // 11
5637 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5638 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5639 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5640 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5641 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5642 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5643 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5644 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5645 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5646 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5647 // 21
5648 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5649 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5650 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5651 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5652 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5653 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5654 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5655 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5656 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5657 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5658 // 31
5659 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5660 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5661 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5662 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5663 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5664 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5665 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5666 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5667 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5668 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5669 // Dirs
5670 // 41
5671 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5672 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5673 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5674 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5675 // 45
5676 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5677 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5678 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5679 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5680 // 49
5681 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5682 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5683 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5684 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5685 // 53
5686 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5687 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5688 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5689 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5690 // Mods
5691 // 57
5692 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5693 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5694 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5695 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5696 // 61
5697 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5698 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5699 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5700 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5701 // 65
5702 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5703 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5704 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5705 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5706 // 69
5707 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5708 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5709 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5710 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5711 // 73
5712 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5713 };
5714
5715 /*
5716 int32_t midi_dp[3] = {0,147,104};
5717 int32_t digi_dp[3] = {1,147,120};
5718 int32_t pan_dp[3] = {0,147,136};
5719 int32_t buf_dp[3] = {0,147,152};
5720 */
5721 int32_t midi_dp[3] = {0,0,0};
5722 int32_t digi_dp[3] = {1,0,0};
5723 int32_t emus_dp[3] = {2,0,0};
5724 int32_t buf_dp[3] = {0,0,0};
5725 int32_t sfx_dp[3] = {3,0,0};
5726 int32_t pan_dp[3] = {0,0,0};
5727
5728 static DIALOG sound_dlg[] =
5729 {
5730 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5731 46 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5732 46 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5733 46 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5734 46 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5735 46 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5736 46 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5737 46 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5738 46 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5739 46 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5740 46 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5741 // 10
5742 46 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5743 46 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5744 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5745 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5746 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5747 46 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5748 46 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5749 46 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5750 46 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5751 46 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5752 //20
5753 46 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5754 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 46 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5758 46 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5759 46 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5760 46 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5761 46 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5762 46 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5763 //30
5764 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5765 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5766 46 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5767 46 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5768 };
5769
5770 char zc_builddate[80];
5771 char zc_aboutstr[80];
5772
5773 static DIALOG about_dlg[] =
5774 {
5775 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5776 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5777 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5778 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5779 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5780 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5781 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5782 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5783 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5784 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5785 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5786 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5787 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5788 };
5789
5790
5791 static DIALOG quest_dlg[] =
5792 {
5793 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5794 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5795 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5796 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5797 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5798 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5799 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5800 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5801 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5802 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5803 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5804 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5805 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5806 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5807 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5808 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5809 };
5810
5811 static DIALOG triforce_dlg[] =
5812 {
5813 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5814 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5815 // 1
5816 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5817 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5818 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5819 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5820 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5821 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5822 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5823 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5824 // 9
5825 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5826 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5827 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5828 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5829 };
5830
5831 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5832 {
5833 go();
5834 int32_t ret=0;
5835 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5836 comeback();
5837 return ret != 0;
5838 }
5839
5840
5841 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5842 {
5843 if(def!=modulepath)
5844 strcpy(modulepath,def);
5845
5846 if(!usefilename)
5847 {
5848 int32_t i=(int32_t)strlen(modulepath);
5849
5850 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5851 modulepath[i--]=0;
5852 }
5853
5854 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5855 int32_t ret=0;
5856 int32_t sel=0;
5857
5858 if(list==NULL)
5859 {
5860 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5861 }
5862 else
5863 {
5864 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5865 }
5866
5867 return ret!=0;
5868 }
5869
5870 //The Dialogue that loads a ZMOD Module File
5871 int32_t zc_load_zmod_module_file()
5872 {
5873 if ( Playing )
5874 {
5875 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5876 return -1;
5877 }
5878 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5879 return D_CLOSE;
5880
5881 FILE *tempmodule = fopen(modulepath,"r");
5882
5883 if(tempmodule == NULL)
5884 {
5885 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5886 return -1;
5887 }
5888
5889
5890 //Set the module path:
5891 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5892 strcpy(moduledata.module_name, modulepath);
5893 al_trace("New Module Path is: %s \n", moduledata.module_name);
5894 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5895 zcm.init(true); //Load the module values.
5896 moduledata.refresh_title_screen = 1;
5897 // refresh_select_screen = 1;
5898 build_biic_list();
5899 return D_O_K;
5900 }
5901
5902 static DIALOG module_info_dlg[] =
5903 {
5904 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5905
5906
5907 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5908 //1
5909 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5910 //2
5911 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5913 //4
5914 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5915 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5917 //7
5918
5919 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5920 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5921 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5922 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5923 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5924 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5925 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5926 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5927 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5928
5929 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5930 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5931 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5932 };
5933
5934 void about_zcplayer_module(const char *prompt,int32_t initialval)
5935 {
5936
5937 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5938 if ( moduledata.moduletitle[0] != 0 )
5939 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5940
5941 if ( moduledata.moduleauthor[0] != 0 )
5942 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5943
5944 if ( moduledata.moduleinfo0[0] != 0 )
5945 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5946 if ( moduledata.moduleinfo1[0] != 0 )
5947 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5948 if ( moduledata.moduleinfo2[0] != 0 )
5949 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5950 if ( moduledata.moduleinfo3[0] != 0 )
5951 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5952 if ( moduledata.moduleinfo4[0] != 0 )
5953 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5954
5955 char module_date[255];
5956 memset(module_date, 0, sizeof(module_date));
5957 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5958 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5959
5960
5961
5962 char module_vers[255];
5963 memset(module_vers, 0, sizeof(module_vers));
5964 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5965
5966
5967 //sprintf(tilecount,"%d",1);
5968
5969 char module_build[255];
5970 memset(module_build, 0, sizeof(module_build));
5971 if ( moduledata.modbeta )
5972 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5973 else
5974 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5975
5976 module_info_dlg[12].dp = (char*)module_date;
5977 module_info_dlg[13].dp = (char*)module_vers;
5978 module_info_dlg[14].dp = (char*)module_build;
5979
5980 large_dialog(module_info_dlg);
5981
5982 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5983 jwin_center_dialog(module_info_dlg);
5984
5985
5986 }
5987
5988 int32_t onAbout_ZCP_Module()
5989 {
5990 about_zcplayer_module("About Module (.zmod)", 0);
5991 return D_O_K;
5992 }
5993
5994 //New Modules Menu for 2.55+
5995 static MENU zcmodule_menu[] =
5996 {
5997 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5998 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5999
6000 { NULL, NULL, NULL, 0, NULL }
6001 };
6002
6003 int32_t onToggleRecordingNewSaves()
6004 {
6005 if (zc_get_config("zeldadx", "replay_new_saves", false))
6006 {
6007 zc_set_config("zeldadx", "replay_new_saves", false);
6008 }
6009 else
6010 {
6011 zc_set_config("zeldadx", "replay_new_saves", true);
6012 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6013 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6014 }
6015 return D_O_K;
6016 }
6017
6018 int32_t onToggleSnapshotAllFrames()
6019 {
6020 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6021 return D_O_K;
6022 }
6023
6024 int32_t onStopReplayOrRecord()
6025 {
6026 if (replay_is_replaying())
6027 {
6028 replay_quit();
6029 }
6030 else if (replay_get_mode() == ReplayMode::Record)
6031 {
6032 if (!replay_get_meta_bool("test_mode"))
6033 {
6034 jwin_alert("Recording", "You cannot stop recording a save file.",
6035 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6036 return D_CLOSE;
6037 }
6038
6039 if (jwin_alert("Stop Recording",
6040 "Save replay to disk and stop recording?",
6041 "This will stop the recording.",
6042 NULL,
6043 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6044 return D_CLOSE;
6045
6046 replay_save();
6047 replay_stop();
6048 }
6049 return D_O_K;
6050 }
6051
6052 static int32_t handle_on_load_replay(ReplayMode mode)
6053 {
6054 if (Playing)
6055 {
6056 if (jwin_alert("Replay - Warning!",
6057 "Loading a replay will exit the current game.",
6058 "All unsaved progress will be lost.",
6059 "Do you wish to continue?",
6060 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6061 return D_CLOSE;
6062 }
6063
6064 std::string mode_string = replay_mode_to_string(mode);
6065 mode_string[0] = std::toupper(mode_string[0]);
6066
6067 std::string line_1 = "Select a replay file to play back.";
6068 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6069 std::string line_3 = "You can stop the replay and take over manually any time.";
6070 if (mode == ReplayMode::Update)
6071 {
6072 line_1 = "Select a replay file to update.";
6073 line_2 = "WARNING: be sure to back up the zplay file";
6074 line_3 = "and verify that the updated replay works as expected!";
6075 }
6076
6077 if (jwin_alert(mode_string.c_str(),
6078 line_1.c_str(),
6079 line_2.c_str(),
6080 line_3.c_str(),
6081 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6082 {
6083 char replay_path[2048];
6084 strcpy(replay_path, "replays/");
6085 if (jwin_file_select_ex(
6086 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6087 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6088 return D_CLOSE;
6089
6090 replay_quit();
6091 load_replay_file_deferred(mode, replay_path);
6092 Quit = qRESET;
6093 return D_CLOSE;
6094 }
6095 return D_O_K;
6096 }
6097
6098 int32_t onLoadReplay()
6099 {
6100 return handle_on_load_replay(ReplayMode::Replay);
6101 }
6102
6103 int32_t onLoadReplayAssert()
6104 {
6105 return handle_on_load_replay(ReplayMode::Assert);
6106 }
6107
6108 int32_t onLoadReplayUpdate()
6109 {
6110 return handle_on_load_replay(ReplayMode::Update);
6111 }
6112
6113 int32_t onSaveReplay()
6114 {
6115 if (replay_get_mode() == ReplayMode::Record)
6116 {
6117 if (!replay_get_meta_bool("test_mode"))
6118 {
6119 if (jwin_alert("Save Replay",
6120 "This will save a copy of the replay up to this point.",
6121 "The official replay file will be untouched.",
6122 "Do you wish to continue?",
6123 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6124 return D_CLOSE;
6125
6126 char replay_path[2048];
6127 strcpy(replay_path, replay_get_replay_path().string().c_str());
6128 if (jwin_file_select_ex(
6129 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6130 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6131 return D_CLOSE;
6132
6133 if (fileexists(replay_path))
6134 {
6135 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6136 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6137 return D_CLOSE;
6138 }
6139
6140 replay_save(replay_path);
6141 }
6142 else
6143 {
6144 replay_save();
6145 }
6146 }
6147 return D_O_K;
6148 }
6149
6150 static MENU replay_menu[] =
6151 {
6152 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6153 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6154 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6155 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6156 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6157 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6158 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6159
6160 { NULL, NULL, NULL, 0, NULL }
6161 };
6162
6163 static DIALOG credits_dlg[] =
6164 {
6165 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6166 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6167 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6168 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6169 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6170 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6171 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6172 };
6173
6174 46 static ListData dmap_list(dmaplist, &font);
6175
6176 static DIALOG goto_dlg[] =
6177 {
6178 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6179 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6180 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6181 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6182 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6183 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6184 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6185 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6186 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6187 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6188 };
6189
6190 int32_t onGoTo()
6191 {
6192 bool music = false;
6193 music = music;
6194 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6195
6196 goto_dlg[0].dp2=get_zc_font(font_lfont);
6197 goto_dlg[4].d2=cheat_goto_dmap;
6198 goto_dlg[6].dp=cheat_goto_screen_str;
6199
6200 clear_keybuf();
6201
6202 large_dialog(goto_dlg);
6203
6204 if(zc_popup_dialog(goto_dlg,4)==1)
6205 {
6206 // dmap, screen
6207 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6208 };
6209
6210 return D_O_K;
6211 }
6212
6213 int32_t onGoToComplete()
6214 {
6215 if(!Playing)
6216 {
6217 return D_O_K;
6218 }
6219
6220 enter_sys_pal();
6221 music_pause();
6222 pause_all_sfx();
6223 onGoTo();
6224 eat_buttons();
6225
6226 zc_readrawkey(KEY_ESC);
6227
6228 exit_sys_pal();
6229 music_resume();
6230 resume_all_sfx();
6231 return D_O_K;
6232 }
6233
6234 int32_t onCredits()
6235 {
6236 go();
6237
6238 BITMAP *win = create_bitmap_ex(8,222,110);
6239
6240 if(!win)
6241 return D_O_K;
6242
6243 int32_t c=0;
6244 int32_t l=0;
6245 int32_t ol=-1;
6246 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6247 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6248 PALETTE tmppal;
6249
6250 rti_gui.transparency_index = 1;
6251
6252 clear_to_color(win, rti_gui.transparency_index);
6253 draw_rle_sprite(win,rle,0,0);
6254 credits_dlg[0].dp2=get_zc_font(font_lfont);
6255 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6256 credits_dlg[2].dp = win;
6257
6258 zc_set_palette_range(black_palette,0,127,false);
6259
6260 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6261
6262 BITMAP* old_screen = screen;
6263 BITMAP* gui_bmp = zc_get_gui_bmp();
6264 ASSERT(gui_bmp);
6265 clear_to_color(gui_bmp, rti_gui.transparency_index);
6266 screen = gui_bmp;
6267
6268 while(update_dialog(p))
6269 {
6270 throttleFPS();
6271 ++c;
6272 l = zc_max((c>>1)-30,0);
6273
6274 if(l > rle->h)
6275 l = c = 0;
6276
6277 if(l > rle->h - 112)
6278 l = rle->h - 112;
6279
6280 clear_bitmap(win);
6281 draw_rle_sprite(win,rle,0,0-l);
6282
6283 if(c<=64)
6284 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6285
6286 zc_set_palette_range(tmppal,0,127,false);
6287
6288 if(l!=ol)
6289 {
6290 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6291 SCRFIX();
6292 ol=l;
6293 }
6294
6295 update_hw_screen();
6296 }
6297
6298 screen = old_screen;
6299 system_pal(true);
6300 sys_mouse();
6301
6302 shutdown_dialog(p);
6303 destroy_bitmap(win);
6304 //comeback();
6305
6306 rti_gui.transparency_index = 0;
6307 clear_to_color(gui_bmp, rti_gui.transparency_index);
6308
6309 return D_O_K;
6310 }
6311
6312 const char *midilist(int32_t index, int32_t *list_size)
6313 {
6314 if(index<0)
6315 {
6316 *list_size=0;
6317
6318 for(int32_t i=0; i<MAXMIDIS; i++)
6319 if(tunes[i].data)
6320 ++(*list_size);
6321
6322 return NULL;
6323 }
6324
6325 int32_t i=0,m=0;
6326
6327 while(m<=index && i<=MAXMIDIS)
6328 {
6329 if(tunes[i].data)
6330 ++m;
6331
6332 ++i;
6333 }
6334
6335 --i;
6336
6337 if(i==MAXMIDIS && m<index)
6338 return "(null)";
6339
6340 return tunes[i].title;
6341 }
6342
6343 /* ------- MIDI info stuff -------- */
6344
6345 char *text;
6346 midi_info *zmi;
6347 bool dialog_running;
6348 bool listening;
6349
6350 void get_info(int32_t index);
6351
6352 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6353 {
6354 int32_t d2 = d->d2;
6355 int32_t ret = jwin_droplist_proc(msg,d,c);
6356
6357 if(d2!=d->d2)
6358 {
6359 get_info(d->d2);
6360 }
6361
6362 return ret;
6363 }
6364
6365 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6366 {
6367 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6368
6369 int32_t ret = jwin_button_proc(msg,d,c);
6370
6371 if(ret == D_CLOSE)
6372 {
6373 // get current midi index
6374 int32_t index = (d+(d->d1))->d2;
6375 int32_t i=0, m=0;
6376
6377 while(m<=index && i<=MAXMIDIS)
6378 {
6379 if(tunes[i].data)
6380 ++m;
6381
6382 ++i;
6383 }
6384
6385 --i;
6386 jukebox(i);
6387 listening = true;
6388 ret = D_O_K;
6389 }
6390
6391 return ret;
6392 }
6393
6394 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6395 {
6396 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6397
6398 int32_t ret = jwin_button_proc(msg,d,c);
6399
6400 if(ret == D_CLOSE)
6401 {
6402 // get current midi index
6403 int32_t index = (d+(d->d1))->d2;
6404 int32_t i=0, m=0;
6405
6406 while(m<=index && i<=MAXMIDIS)
6407 {
6408 if(tunes[i].data)
6409 ++m;
6410
6411 ++i;
6412 }
6413
6414 --i;
6415
6416 // get file name
6417
6418 int32_t sel=0;
6419 //struct ffblk f;
6420 char title[40] = "Save MIDI: ";
6421 char fname[2048];
6422 memset(fname,0,2048);
6423 static EXT_LIST list[] =
6424 {
6425 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6426 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6427 { NULL, NULL }
6428 };
6429
6430 strcpy(title+11, tunes[i].title);
6431 title[39] = '\0';
6432
6433 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6434 goto done;
6435
6436 if(exists(fname))
6437 {
6438 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6439 goto done;
6440 }
6441
6442 // save midi i
6443
6444 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6445 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6446
6447 done:
6448 chop_path(fname);
6449 ret = D_REDRAW;
6450 }
6451
6452 return ret;
6453 }
6454
6455 46 static ListData midi_list(midilist, &font);
6456
6457 static DIALOG midi_dlg[] =
6458 {
6459 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6460 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6461 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6462 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6463 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6464 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6465 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6466 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6467 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6468 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6469 };
6470
6471 void get_info(int32_t index)
6472 {
6473 int32_t i=0, m=0;
6474
6475 while(m<=index && i<=MAXMIDIS)
6476 {
6477 if(tunes[i].data)
6478 ++m;
6479
6480 ++i;
6481 }
6482
6483 --i;
6484
6485 if(i==MAXMIDIS && m<index)
6486 strcpy(text,"(null)");
6487 else
6488 {
6489 get_midi_info((MIDI*)tunes[i].data,zmi);
6490 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6491 }
6492
6493 midi_dlg[0].dp2=get_zc_font(font_lfont);
6494 midi_dlg[3].dp = text;
6495 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6496 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6497
6498 if(dialog_running)
6499 {
6500 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6501 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6502 }
6503 }
6504
6505 int32_t onMIDICredits()
6506 {
6507 text = (char*)malloc(4096);
6508 zmi = (midi_info*)malloc(sizeof(midi_info));
6509
6510 if(!text || !zmi)
6511 {
6512 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6513 return D_O_K;
6514 }
6515
6516 bool do_pause_midi = midi_pos >= 0 && currmidi;
6517 auto restore_midi = currmidi;
6518 if(do_pause_midi)
6519 {
6520 paused_midi_pos = midi_pos;
6521 stop_midi();
6522 midi_suspended = midissuspHALTED;
6523 }
6524
6525 midi_dlg[0].dp2=get_zc_font(font_lfont);
6526 midi_dlg[2].d1 = 0;
6527 midi_dlg[2].d2 = 0;
6528 midi_dlg[4].flags = D_EXIT;
6529 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6530
6531 listening = false;
6532 dialog_running=false;
6533 get_info(0);
6534
6535 dialog_running=true;
6536
6537 large_dialog(midi_dlg);
6538
6539 zc_popup_dialog(midi_dlg,0);
6540 dialog_running=false;
6541
6542 if(listening)
6543 music_stop();
6544
6545 if(do_pause_midi)
6546 {
6547 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6548 midi_suspended = midissuspRESUME;
6549 currmidi = restore_midi;
6550 midi_pos = paused_midi_pos;
6551 }
6552
6553 if(text) free(text);
6554 if(zmi) free(zmi);
6555 return D_O_K;
6556 }
6557
6558 int32_t onAbout()
6559 {
6560 char buf1[80]={0};
6561 std::ostringstream oss;
6562 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6563 oss << buf1 << '\n';
6564 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6565 oss << buf1 << '\n';
6566 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6567 oss << buf1 << '\n';
6568 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6569 oss << buf1 << '\n';
6570 sprintf(buf1, "Tag: %s", getReleaseTag());
6571 oss << buf1 << '\n';
6572
6573 InfoDialog("About ZC", oss.str()).show();
6574 return D_O_K;
6575 }
6576
6577 int32_t onQuest()
6578 {
6579 char fname[100];
6580 strcpy(fname, get_filename(qstpath));
6581 quest_dlg[0].dp2=get_zc_font(font_lfont);
6582 quest_dlg[1].dp = fname;
6583
6584 if(QHeader.quest_number==0)
6585 sprintf(str_a,"Custom");
6586 else
6587 sprintf(str_a,"%d",QHeader.quest_number);
6588
6589 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6590
6591 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6592 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6593
6594 large_dialog(quest_dlg);
6595
6596 zc_popup_dialog(quest_dlg, 0);
6597 return D_O_K;
6598 }
6599
6600 void call_vidmode_dlg();
6601 int32_t onVidMode()
6602 {
6603 call_vidmode_dlg();
6604 return D_O_K;
6605 }
6606
6607 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6608 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6609 //Added an extra statement, so that if the key is cleared to 0, the cleared
6610 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6611
6612 void load_ukeys(int32_t* arr)
6613 {
6614 arr[ukey_a] = Akey;
6615 arr[ukey_b] = Bkey;
6616 arr[ukey_s] = Skey;
6617 arr[ukey_l] = Lkey;
6618 arr[ukey_r] = Rkey;
6619 arr[ukey_p] = Pkey;
6620 arr[ukey_ex1] = Exkey1;
6621 arr[ukey_ex2] = Exkey2;
6622 arr[ukey_ex3] = Exkey3;
6623 arr[ukey_ex4] = Exkey4;
6624 arr[ukey_du] = DUkey;
6625 arr[ukey_dd] = DDkey;
6626 arr[ukey_dl] = DLkey;
6627 arr[ukey_dr] = DRkey;
6628 arr[ukey_mod1a] = cheat_modifier_keys[0];
6629 arr[ukey_mod1b] = cheat_modifier_keys[1];
6630 arr[ukey_mod2a] = cheat_modifier_keys[2];
6631 arr[ukey_mod2b] = cheat_modifier_keys[3];
6632 };
6633
6634 static const char* ukey_names[] = {
6635 "A", "B", "Start", "L", "R", "Map",
6636 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6637 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6638 "Cheat Mod R1", "Cheat Mod R2",
6639 };
6640 std::string get_ukey_name(int32_t k)
6641 {
6642 if (k < num_ukey) return ukey_names[k];
6643 return "";
6644 }
6645
6646 int32_t onKeyboard()
6647 {
6648 int32_t a = Akey;
6649 int32_t b = Bkey;
6650 int32_t s = Skey;
6651 int32_t l = Lkey;
6652 int32_t r = Rkey;
6653 int32_t p = Pkey;
6654 int32_t ex1 = Exkey1;
6655 int32_t ex2 = Exkey2;
6656 int32_t ex3 = Exkey3;
6657 int32_t ex4 = Exkey4;
6658 int32_t du = DUkey;
6659 int32_t dd = DDkey;
6660 int32_t dl = DLkey;
6661 int32_t dr = DRkey;
6662 int32_t mod1a = cheat_modifier_keys[0];
6663 int32_t mod1b = cheat_modifier_keys[1];
6664 int32_t mod2a = cheat_modifier_keys[2];
6665 int32_t mod2b = cheat_modifier_keys[3];
6666 bool done=false;
6667 int32_t ret;
6668
6669 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6670
6671 large_dialog(keyboard_control_dlg);
6672
6673 while(!done)
6674 {
6675 ret = zc_popup_dialog(keyboard_control_dlg,3);
6676
6677 if(ret==3) // OK
6678 {
6679 int32_t ukeys[num_ukey];
6680 load_ukeys(ukeys);
6681 std::vector<std::string> uniqueError;
6682 for(int32_t q = 0; q < num_ukey; ++q)
6683 {
6684 for(int32_t p = q+1; p < num_ukey; ++p)
6685 {
6686 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6687 {
6688 char buf[64];
6689 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6690 std::string str(buf);
6691 uniqueError.push_back(str);
6692 }
6693 }
6694 }
6695 if(uniqueError.size() == 0)
6696 {
6697 done = true;
6698 save_control_configs(true);
6699 }
6700 else
6701 {
6702 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6703 box_out("Cannot have duplicate keybinds!"); box_eol();
6704 for(std::vector<std::string>::iterator it = uniqueError.begin();
6705 it != uniqueError.end(); ++it)
6706 {
6707 box_out((*it).c_str()); box_eol();
6708 }
6709 box_end(true);
6710 }
6711 }
6712 else // Cancel
6713 {
6714 Akey = a;
6715 Bkey = b;
6716 Skey = s;
6717 Lkey = l;
6718 Rkey = r;
6719 Pkey = p;
6720 Exkey1 = ex1;
6721 Exkey2 = ex2;
6722 Exkey3 = ex3;
6723 Exkey4 = ex4;
6724 DUkey = du;
6725 DDkey = dd;
6726 DLkey = dl;
6727 DRkey = dr;
6728 cheat_modifier_keys[0] = mod1a;
6729 cheat_modifier_keys[1] = mod1b;
6730 cheat_modifier_keys[2] = mod2a;
6731 cheat_modifier_keys[3] = mod2b;
6732
6733 done=true;
6734 }
6735
6736 rest(1);
6737 }
6738
6739 return D_O_K;
6740 }
6741
6742 int32_t onGamepad()
6743 {
6744 int32_t a = Abtn;
6745 int32_t b = Bbtn;
6746 int32_t s = Sbtn;
6747 int32_t l = Lbtn;
6748 int32_t r = Rbtn;
6749 int32_t m = Mbtn;
6750 int32_t p = Pbtn;
6751 int32_t ex1 = Exbtn1;
6752 int32_t ex2 = Exbtn2;
6753 int32_t ex3 = Exbtn3;
6754 int32_t ex4 = Exbtn4;
6755 int32_t up = DUbtn;
6756 int32_t down = DDbtn;
6757 int32_t left = DLbtn;
6758 int32_t right = DRbtn;
6759
6760 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6761 if(analog_movement)
6762 gamepad_dlg[56].flags|=D_SELECTED;
6763 else
6764 gamepad_dlg[56].flags&=~D_SELECTED;
6765
6766 large_dialog(gamepad_dlg);
6767
6768 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6769
6770 if(ret == 4) //OK
6771 {
6772 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6773 save_control_configs(false);
6774 }
6775 else //Cancel
6776 {
6777 Abtn = a;
6778 Bbtn = b;
6779 Sbtn = s;
6780 Lbtn = l;
6781 Rbtn = r;
6782 Mbtn = m;
6783 Pbtn = p;
6784 Exbtn1 = ex1;
6785 Exbtn2 = ex2;
6786 Exbtn3 = ex3;
6787 Exbtn4 = ex4;
6788 DUbtn = up;
6789 DDbtn = down;
6790 DLbtn = left;
6791 DRbtn = right;
6792 }
6793
6794 return D_O_K;
6795 }
6796
6797 int32_t onCheatKeys()
6798 {
6799 int32_t oldcheats[Cheat::Last][2];
6800 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6801
6802 bool done=false;
6803
6804 while(!done)
6805 {
6806 bool confirm = false;
6807 CheatKeysDialog(&confirm).show();
6808 if(confirm) // OK
6809 {
6810 std::vector<std::string> uniqueError;
6811 char buf[512];
6812 for(size_t q = 1; q < Cheat::Last; ++q)
6813 {
6814 if(cheatkeys[q][1] && !cheatkeys[q][0])
6815 {
6816 cheatkeys[q][0] = cheatkeys[q][1];
6817 cheatkeys[q][1] = 0;
6818 }
6819 }
6820 for(size_t q = 1; q < Cheat::Last; ++q)
6821 {
6822 if(!bindable_cheat((Cheat)q)) continue;
6823 for(size_t p = q+1; p < Cheat::Last; ++p)
6824 {
6825 if(!bindable_cheat((Cheat)p)) continue;
6826 for(size_t q2 = 0; q2 <= 1; ++q2)
6827 for(size_t p2 = 0; p2 <= 1; ++p2)
6828 {
6829 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6830 {
6831 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6832 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6833 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6834 get_keystr(cheatkeys[q][q2])));
6835 }
6836 }
6837 }
6838 }
6839 if(uniqueError.size() == 0)
6840 {
6841 done = true;
6842 save_cheatkeys();
6843 }
6844 else
6845 {
6846 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6847 box_out("Cannot have duplicate keybinds!"); box_eol();
6848 for(std::vector<std::string>::iterator it = uniqueError.begin();
6849 it != uniqueError.end(); ++it)
6850 {
6851 box_out((*it).c_str()); box_eol();
6852 }
6853 box_end(true);
6854 }
6855 }
6856 else // Cancel
6857 {
6858 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6859 done=true;
6860 }
6861 rest(1);
6862 }
6863
6864 return D_O_K;
6865 }
6866
6867 int32_t onSound()
6868 {
6869 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6870 {
6871 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6872 }
6873 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6874 {
6875 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6876 }
6877 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6878 {
6879 emusic_volume = (int32_t)FFCore.usr_music_volume;
6880 }
6881 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6882 {
6883 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6884 }
6885 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6886 {
6887 pan_style = (int32_t)FFCore.usr_panstyle;
6888 }
6889
6890 int32_t m = midi_volume;
6891 int32_t d = digi_volume;
6892 int32_t e = emusic_volume;
6893 int32_t b = zcmusic_bufsz;
6894 int32_t s = sfx_volume;
6895 int32_t p = pan_style;
6896 pan_style = vbound(pan_style,0,3);
6897
6898 sound_dlg[0].dp2=get_zc_font(font_lfont);
6899
6900 large_dialog(sound_dlg);
6901
6902 midi_dp[1] = sound_dlg[6].x;
6903 midi_dp[2] = sound_dlg[6].y;
6904 digi_dp[1] = sound_dlg[7].x;
6905 digi_dp[2] = sound_dlg[7].y;
6906 emus_dp[1] = sound_dlg[8].x;
6907 emus_dp[2] = sound_dlg[8].y;
6908 buf_dp[1] = sound_dlg[9].x;
6909 buf_dp[2] = sound_dlg[9].y;
6910 sfx_dp[1] = sound_dlg[10].x;
6911 sfx_dp[2] = sound_dlg[10].y;
6912 pan_dp[1] = sound_dlg[11].x;
6913 pan_dp[2] = sound_dlg[11].y;
6914 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6915 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6916 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6917 sound_dlg[18].d2 = zcmusic_bufsz;
6918 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6919 sound_dlg[20].d2 = pan_style;
6920
6921 int32_t ret = zc_popup_dialog(sound_dlg,1);
6922
6923 if(ret==2)
6924 {
6925 master_volume(digi_volume,midi_volume);
6926 if (zcmusic)
6927 zcmusic_set_volume(zcmusic, emusic_volume);
6928
6929 for(int32_t i=0; i<WAV_COUNT; ++i)
6930 {
6931 //allegro assertion fails when passing in -1 as voice -DD
6932 if(sfx_voice[i] > 0)
6933 voice_set_volume(sfx_voice[i], sfx_volume);
6934 }
6935 zc_set_config(sfx_sect,"digi",digi_volume);
6936 zc_set_config(sfx_sect,"midi",midi_volume);
6937 zc_set_config(sfx_sect,"sfx",sfx_volume);
6938 zc_set_config(sfx_sect,"emusic",emusic_volume);
6939 zc_set_config(sfx_sect,"pan",pan_style);
6940 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6941 }
6942 else
6943 {
6944 midi_volume = m;
6945 digi_volume = d;
6946 emusic_volume = e;
6947 zcmusic_bufsz = b;
6948 sfx_volume = s;
6949 pan_style = p;
6950 }
6951
6952 return D_O_K;
6953 }
6954
6955 int32_t queding(char const* s1, char const* s2, char const* s3)
6956 {
6957 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6958 }
6959
6960 int32_t onQuit()
6961 {
6962 if(Playing)
6963 {
6964 int32_t ret=0;
6965
6966 if(get_qr(qr_NOCONTINUE))
6967 {
6968 if(standalone_mode)
6969 {
6970 ret=queding("End current game?",
6971 "The continue screen is disabled; the game",
6972 "will be reloaded from the last save.");
6973 }
6974 else
6975 {
6976 ret=queding("End current game?",
6977 "The continue screen is disabled. You will",
6978 "be returned to the file select screen.");
6979 }
6980 }
6981 else
6982 ret=queding("End current game?",NULL,NULL);
6983
6984 if(ret==1)
6985 {
6986 disableClickToFreeze=false;
6987 Quit=qQUIT;
6988
6989 // Trying to evade a door repair charge?
6990 if(repaircharge)
6991 {
6992 game->change_drupy(-repaircharge);
6993 repaircharge=0;
6994 }
6995
6996 return D_CLOSE;
6997 }
6998 }
6999
7000 return D_O_K;
7001 }
7002
7003 int32_t onTryQuitMenu()
7004 {
7005 return onTryQuit(true);
7006 }
7007
7008 int32_t onTryQuit(bool inMenu)
7009 {
7010 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7011 {
7012 if(active_cutscene.can_f6())
7013 {
7014 if(get_qr(qr_OLD_F6))
7015 {
7016 if(inMenu) onQuit();
7017 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7018 }
7019 else
7020 {
7021 disableClickToFreeze=false;
7022 GameFlags |= GAMEFLAG_TRYQUIT;
7023 }
7024 return D_CLOSE;
7025 }
7026 else active_cutscene.error();
7027 }
7028
7029 return D_O_K;
7030 }
7031
7032 int32_t onReset()
7033 {
7034 if(queding(" Reset system? ",NULL,NULL)==1)
7035 {
7036 disableClickToFreeze=false;
7037 Quit=qRESET;
7038 replay_quit();
7039 return D_CLOSE;
7040 }
7041
7042 return D_O_K;
7043 }
7044
7045 int32_t onExit()
7046 {
7047 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7048 {
7049 Quit=qEXIT;
7050 return D_CLOSE;
7051 }
7052
7053 return D_O_K;
7054 }
7055
7056 int32_t onTitle_NES()
7057 {
7058 title_version=0;
7059 zc_set_config(cfg_sect,"title",title_version);
7060 return D_O_K;
7061 }
7062 int32_t onTitle_DX()
7063 {
7064 title_version=1;
7065 zc_set_config(cfg_sect,"title",title_version);
7066 return D_O_K;
7067 }
7068 int32_t onTitle_25()
7069 {
7070 title_version=2;
7071 zc_set_config(cfg_sect,"title",title_version);
7072 return D_O_K;
7073 }
7074
7075 int32_t onDebug()
7076 {
7077 if(debug_enabled)
7078 set_debug(!get_debug());
7079 return D_O_K;
7080 }
7081
7082 int32_t onHeartBeep()
7083 {
7084 heart_beep=!heart_beep;
7085 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7086 return D_O_K;
7087 }
7088
7089 int32_t onSaveIndicator()
7090 {
7091 use_save_indicator = use_save_indicator ? 0 : 1;
7092 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7093 return D_O_K;
7094 }
7095
7096 int32_t onEpilepsy()
7097 {
7098 if(jwin_alert3(
7099 "Epilepsy Flash Reduction",
7100 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7101 "Disabling this will restore standard flash and wavy behaviour.",
7102 "Proceed?",
7103 "&Yes",
7104 "&No",
7105 NULL,
7106 'y',
7107 'n',
7108 0,
7109 get_zc_font(font_lfont)) == 1)
7110 {
7111 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7112 zc_set_config("zeldadx","checked_epilepsy",1);
7113 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7114 }
7115 return D_O_K;
7116 }
7117
7118 int32_t onTriforce()
7119 {
7120 for(int32_t i=0; i<MAXINITTABS; ++i)
7121 {
7122 init_tabs[i].flags&=~D_SELECTED;
7123 }
7124
7125 init_tabs[3].flags=D_SELECTED;
7126 return onCheatConsole();
7127 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7128 for(int32_t i=1; i<=8; i++)
7129 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7130
7131 if(zc_popup_dialog (triforce_dlg,-1)==9)
7132 {
7133 for(int32_t i=1; i<=8; i++)
7134 {
7135 game->lvlitems[i] &= ~liTRIFORCE;
7136 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7137 }
7138 }
7139 return D_O_K;*/
7140 }
7141
7142 bool rc = false;
7143 /*
7144 int32_t onEquipment()
7145 {
7146 for (int32_t i=0; i<MAXINITTABS; ++i)
7147 {
7148 init_tabs[i].flags&=~D_SELECTED;
7149 }
7150 init_tabs[0].flags=D_SELECTED;
7151 return onCheatConsole();
7152 }
7153 */
7154
7155 int32_t onItems()
7156 {
7157 for(int32_t i=0; i<MAXINITTABS; ++i)
7158 {
7159 init_tabs[i].flags&=~D_SELECTED;
7160 }
7161
7162 init_tabs[1].flags=D_SELECTED;
7163 return onCheatConsole();
7164 }
7165
7166 static DIALOG getnum_dlg[] =
7167 {
7168 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7169 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7170 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7171 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7172 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7173 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7174 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7175 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7176 };
7177
7178 int32_t getnumber(const char *prompt,int32_t initialval)
7179 {
7180 char buf[20];
7181 sprintf(buf,"%d",initialval);
7182 getnum_dlg[0].dp=(void *)prompt;
7183 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7184 getnum_dlg[2].dp=buf;
7185
7186 large_dialog(getnum_dlg);
7187
7188 if(zc_popup_dialog(getnum_dlg,2)==3)
7189 return atoi(buf);
7190
7191 return initialval;
7192 }
7193
7194 int32_t onLife()
7195 {
7196 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7197 cheats_enqueue(Cheat::Life, value);
7198 return D_O_K;
7199 }
7200
7201 int32_t onHeartC()
7202 {
7203 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7204 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7205 cheats_enqueue(Cheat::MaxLife, max_life);
7206 cheats_enqueue(Cheat::Life, life);
7207 return D_O_K;
7208 }
7209
7210 int32_t onMagicC()
7211 {
7212 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7213 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7214 cheats_enqueue(Cheat::MaxMagic, max_magic);
7215 cheats_enqueue(Cheat::Magic, magic);
7216 return D_O_K;
7217 }
7218
7219 int32_t onRupies()
7220 {
7221 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7222 cheats_enqueue(Cheat::Rupies, value);
7223 return D_O_K;
7224 }
7225
7226 int32_t onMaxBombs()
7227 {
7228 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7229 cheats_enqueue(Cheat::MaxBombs, value);
7230 cheats_enqueue(Cheat::Bombs, value);
7231 return D_O_K;
7232 }
7233
7234 int32_t onRefillLife()
7235 {
7236 cheats_enqueue(Cheat::Life, game->get_maxlife());
7237 return D_O_K;
7238 }
7239 int32_t onRefillMagic()
7240 {
7241 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7242 return D_O_K;
7243 }
7244 int32_t onClock()
7245 {
7246 cheats_enqueue(Cheat::Clock);
7247 return D_O_K;
7248 }
7249
7250 int32_t onQstPath()
7251 {
7252 char path[2048];
7253
7254 chop_path(qstdir);
7255 strcpy(path,qstdir);
7256
7257 go();
7258
7259 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7260 {
7261 chop_path(path);
7262 fix_filename_case(path);
7263 fix_filename_slashes(path);
7264 strcpy(qstdir,path);
7265 strcpy(qstpath,qstdir);
7266 }
7267
7268 comeback();
7269 return D_O_K;
7270 }
7271
7272 #include "dialog/cheat_dialog.h"
7273 int32_t onCheat()
7274 {
7275 call_setcheat_dialog();
7276 game->set_cheat(maxcheat);
7277 if(cheat) game->did_cheat(true);
7278 return D_O_K;
7279 }
7280
7281 int32_t onCheatRupies()
7282 {
7283 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7284 return D_O_K;
7285 }
7286
7287 int32_t onCheatArrows()
7288 {
7289 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7290 return D_O_K;
7291 }
7292
7293 int32_t onCheatBombs()
7294 {
7295 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7296 return D_O_K;
7297 }
7298
7299 // *** screen saver
7300
7301 9284954 int32_t after_time()
7302 {
7303
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(ss_enable == 0)
7304 return INT_MAX;
7305
7306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 0)
7307 return 5 * 60;
7308
7309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 3)
7310 return ss_after * 15 * 60;
7311
7312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 13)
7313 return (ss_after - 3) * 60 * 60;
7314
7315 9284954 return MAX_IDLE + 1;
7316 9284954 }
7317
7318 static const char *after_str[15] =
7319 {
7320 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7321 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7322 "Never"
7323 };
7324
7325 const char *after_list(int32_t index, int32_t *list_size)
7326 {
7327 if(index < 0)
7328 {
7329 *list_size = 15;
7330 return NULL;
7331 }
7332
7333 return after_str[index];
7334 }
7335
7336 46 static ListData after__list(after_list, &font);
7337
7338 static DIALOG scrsaver_dlg[] =
7339 {
7340 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7341 46 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7342 46 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7343 46 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7344 46 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7345 46 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7346 46 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7347 46 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7348 46 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7349 46 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7350 46 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7351 46 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7352 46 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7353 46 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7354 };
7355
7356 int32_t onScreenSaver()
7357 {
7358 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7359 int32_t oldcfgs[3];
7360 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7361 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7362 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7363
7364 large_dialog(scrsaver_dlg);
7365
7366 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7367
7368 if(ret == 8 || ret == 9)
7369 {
7370 ss_after = scrsaver_dlg[5].d1;
7371 ss_speed = scrsaver_dlg[6].d2;
7372 ss_density = scrsaver_dlg[7].d2;
7373 if(oldcfgs[0] != ss_after)
7374 zc_set_config(cfg_sect,"ss_after",ss_after);
7375 if(oldcfgs[1] != ss_speed)
7376 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7377 if(oldcfgs[2] != ss_density)
7378 zc_set_config(cfg_sect,"ss_density",ss_density);
7379 }
7380
7381 if(ret == 9)
7382 // preview Screen Saver
7383 {
7384 clear_keybuf();
7385 Matrix(ss_speed, ss_density, 30);
7386 system_pal(true);
7387 sys_mouse();
7388 }
7389
7390 return D_O_K;
7391 }
7392
7393 /***** Menus *****/
7394
7395 static MENU game_menu[] =
7396 {
7397 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7398 { (char *)"", NULL, NULL, 0, NULL },
7399 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7400 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7401 { (char *)"", NULL, NULL, 0, NULL },
7402 #ifdef __EMSCRIPTEN__
7403 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7404 #elif defined(ALLEGRO_MACOSX)
7405 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7406 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7407 #else
7408 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7409 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7410 #endif
7411 { NULL, NULL, NULL, 0, NULL }
7412 };
7413
7414 static MENU title_menu[] =
7415 {
7416 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7417 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7418 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7419 { NULL, NULL, NULL, 0, NULL }
7420 };
7421
7422 static MENU snapshot_format_menu[] =
7423 {
7424 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7425 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7426 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7427 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7428 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7429 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7430 { NULL, NULL, NULL, 0, NULL }
7431 };
7432
7433 static MENU controls_menu[] =
7434 {
7435 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7436 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7437 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7438 { NULL, NULL, NULL, 0, NULL }
7439 };
7440
7441 static MENU name_entry_mode_menu[] =
7442 {
7443 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7444 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7445 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7446 { NULL, NULL, NULL, 0, NULL }
7447 };
7448
7449 static void set_controls_menu_active()
7450 {
7451
7452 }
7453
7454 static MENU window_menu[] =
7455 {
7456 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7457 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7458 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7459 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7460 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7461 { NULL, NULL, NULL, 0, NULL }
7462 };
7463 static MENU options_menu[] =
7464 {
7465 { "&Title Screen", NULL, title_menu, 0, NULL },
7466 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7467 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7468 { "&Window Settings", NULL, window_menu, 0, NULL },
7469 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7470 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7471 { NULL, NULL, NULL, 0, NULL }
7472 };
7473 static MENU settings_menu[] =
7474 {
7475 { "&Sound...", onSound, NULL, 0, NULL },
7476 { "C&ontrols", NULL, controls_menu, 0, NULL },
7477 { "", NULL, NULL, 0, NULL },
7478 { "Options", NULL, options_menu, 0, NULL },
7479 { "", NULL, NULL, 0, NULL },
7480 //
7481 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7482 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7483 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7484 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7485 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7486 //
7487 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7488 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7489 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7490 { "", NULL, NULL, 0, NULL },
7491 { "Debu&g", onDebug, NULL, 0, NULL },
7492 //
7493 { NULL, NULL, NULL, 0, NULL }
7494 };
7495
7496
7497 static MENU misc_menu[] =
7498 {
7499 { (char *)"&About...", onAbout, NULL, 0, NULL },
7500 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7501 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7502 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7503 { (char *)"", NULL, NULL, 0, NULL },
7504 //5
7505 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7506 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7507 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7508 { (char *)"", NULL, NULL, 0, NULL },
7509 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7510 //10
7511 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7512 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7513 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7514 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7515 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7516 //15
7517 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7518 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7519 { NULL, NULL, NULL, 0, NULL }
7520 };
7521
7522 static MENU refill_menu[] =
7523 {
7524 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7525 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7526 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7527 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7528 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7529 { NULL, NULL, NULL, 0, NULL }
7530 };
7531
7532 static MENU show_menu[] =
7533 {
7534 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7535 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7536 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7537 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7538 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7539 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7540 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7541 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7542 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7543 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7544 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7545 { (char *)"", NULL, NULL, 0, NULL },
7546 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7547 { (char *)"", NULL, NULL, 0, NULL },
7548 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7549 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7550 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7551 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7552 { NULL, NULL, NULL, 0, NULL }
7553 };
7554
7555 static MENU cheat_menu[] =
7556 {
7557 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7558 { (char *)"", NULL, NULL, 0, NULL },
7559 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7560 { (char *)"", NULL, NULL, 0, NULL },
7561 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7562 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7563 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7564 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7565 { (char *)"", NULL, NULL, 0, NULL },
7566 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7567 { (char *)"", NULL, NULL, 0, NULL },
7568 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7569 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7570 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7571 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7572 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7573 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7574 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7575 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7576 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7577 { NULL, NULL, NULL, 0, NULL }
7578 };
7579
7580 #if DEVLEVEL > 0
7581 int32_t devLogging();
7582 int32_t devDebug();
7583 int32_t devTimestmp();
7584 #if DEVLEVEL > 1
7585 int32_t setCheat();
7586 #endif //DEVLEVEL > 1
7587 enum
7588 {
7589 dv_log,
7590 // dv_dbg,
7591 dv_tmpstmp,
7592 #if DEVLEVEL > 1
7593 dv_nil,
7594 dv_setcheat,
7595 #endif //DEVLEVEL > 1
7596 dv_max
7597 };
7598 static MENU dev_menu[] =
7599 {
7600 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7601 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7602 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7603 #if DEVLEVEL > 1
7604 { (char *)"", NULL, NULL, 0, NULL },
7605 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7606 #endif //DEVLEVEL > 1
7607 { NULL, NULL, NULL, 0, NULL }
7608 };
7609 int32_t devLogging()
7610 {
7611 dev_logging = !dev_logging;
7612 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7613 return D_O_K;
7614 }
7615 // int32_t devDebug()
7616 // {
7617 // dev_debug = !dev_debug;
7618 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7619 // return D_O_K;
7620 // }
7621 int32_t devTimestmp()
7622 {
7623 dev_timestmp = !dev_timestmp;
7624 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7625 return D_O_K;
7626 }
7627 #if DEVLEVEL > 1
7628 int32_t setCheat()
7629 {
7630 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7631 return D_O_K;
7632 }
7633 #endif //DEVLEVEL > 1
7634 #endif //DEVLEVEL > 0
7635
7636 MENU the_player_menu[] =
7637 {
7638 { (char *)"&Game", NULL, game_menu, 0, NULL },
7639 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7640 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7641 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7642 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7643 #if DEVLEVEL > 0
7644 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7645 #endif
7646 { NULL, NULL, NULL, 0, NULL }
7647 };
7648 int32_t onPauseInBackground()
7649 {
7650 if(jwin_alert3(
7651 "Toggle Pause In Background",
7652 "This action will change whether ZC Player pauses when the window loses focus.",
7653 "",
7654 "Proceed?",
7655 "&Yes",
7656 "&No",
7657 NULL,
7658 'y',
7659 'n',
7660 0,
7661 get_zc_font(font_lfont)) == 1)
7662 {
7663 pause_in_background = pause_in_background ? 0 : 1;
7664 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7665 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7666 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7667 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7668 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7669 }
7670 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7671 return D_O_K;
7672 }
7673
7674 int32_t onKeyboardEntry()
7675 {
7676 NameEntryMode=0;
7677 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7678 return D_O_K;
7679 }
7680
7681 int32_t onLetterGridEntry()
7682 {
7683 NameEntryMode=1;
7684 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7685 return D_O_K;
7686 }
7687
7688 int32_t onExtLetterGridEntry()
7689 {
7690 NameEntryMode=2;
7691 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7692 return D_O_K;
7693 }
7694
7695 static BITMAP* oldscreen;
7696 int32_t onFullscreenMenu()
7697 {
7698 // super hacks
7699 screen = oldscreen;
7700 if (onFullscreen() == D_REDRAW)
7701 {
7702 oldscreen = screen;
7703 }
7704 screen = menu_bmp;
7705 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7706 return D_O_K;
7707 }
7708
7709 46 void fix_menu()
7710 {
7711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(!debug_enabled)
7712 46 settings_menu[13].text = NULL;
7713 46 }
7714
7715 static DIALOG system_dlg[] =
7716 {
7717 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7718 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7719 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7720 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7721 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7722 #ifndef ALLEGRO_MACOSX
7723 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7724 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7725 #else
7726 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7727 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7728 #endif
7729 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7730 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7731 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7732 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7733 };
7734
7735 void reset_snapshot_format_menu()
7736 {
7737 for(int32_t i=0; i<ssfmtMAX; ++i)
7738 {
7739 snapshot_format_menu[i].flags=0;
7740 }
7741 }
7742
7743 int32_t onSetSnapshotFormat()
7744 {
7745 switch(active_menu->text[1])
7746 {
7747 case 'B': //"&BMP"
7748 SnapshotFormat=0;
7749 break;
7750
7751 case 'G': //"&GIF"
7752 SnapshotFormat=1;
7753 break;
7754
7755 case 'J': //"&JPG"
7756 SnapshotFormat=2;
7757 break;
7758
7759 case 'P': //"&PNG"
7760 SnapshotFormat=3;
7761 break;
7762
7763 case 'C': //"PC&X"
7764 SnapshotFormat=4;
7765 break;
7766
7767 case 'T': //"&TGA"
7768 SnapshotFormat=5;
7769 break;
7770
7771 case 'L': //"&LBM"
7772 SnapshotFormat=6;
7773 break;
7774 }
7775 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7776
7777 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7778 return D_O_K;
7779 }
7780
7781
7782 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7783 {
7784 PALETTE tmp;
7785
7786 for(int32_t i=0; i<256; i++)
7787 {
7788 tmp[i].r=r;
7789 tmp[i].g=g;
7790 tmp[i].b=b;
7791 }
7792
7793 fade_interpolate(src,tmp,dest,pos,from,to);
7794 }
7795
7796 13 void system_pal(bool force)
7797 {
7798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(is_sys_pal && !force) return;
7799 13 is_sys_pal = true;
7800 13 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7801 13 hw_palette = &syspal;
7802 13 update_hw_pal = true;
7803 13 }
7804
7805 static uint32_t entered_sys_pal = 0;
7806 13 void enter_sys_pal()
7807 {
7808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(is_sys_pal)
7809 {
7810 if(entered_sys_pal)
7811 ++entered_sys_pal;
7812 return;
7813 }
7814 13 sys_mouse();
7815 13 system_pal(true);
7816 13 ++entered_sys_pal;
7817 13 }
7818 13 void exit_sys_pal()
7819 {
7820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(entered_sys_pal)
7821 {
7822
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!--entered_sys_pal)
7823 {
7824 13 game_pal();
7825 13 game_mouse();
7826 13 }
7827 13 }
7828 13 }
7829
7830 void switch_out_callback()
7831 {
7832 if (pause_in_background && !MenuOpen)
7833 {
7834 System();
7835 }
7836 }
7837
7838 void switch_in_callback()
7839 {
7840 }
7841
7842 421 void game_pal()
7843 {
7844 421 is_sys_pal = false;
7845 421 entered_sys_pal = 0;
7846 421 hw_palette = &RAMpal;
7847 421 update_hw_pal = true;
7848 421 }
7849
7850 static char bar_str[] = "";
7851
7852 13 void music_pause()
7853 {
7854 //al_pause_duh(tmplayer);
7855 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7856 13 zc_midi_pause();
7857 13 }
7858
7859 void music_resume()
7860 {
7861 //al_resume_duh(tmplayer);
7862 zcmusic_pause(zcmusic, ZCM_RESUME);
7863 zc_midi_resume();
7864 }
7865
7866 3358 void music_stop()
7867 {
7868 //al_stop_duh(tmplayer);
7869 //unload_duh(tmusic);
7870 //tmusic=NULL;
7871 //tmplayer=NULL;
7872 3358 zcmusic_stop(zcmusic);
7873 3358 zcmusic_unload_file(zcmusic);
7874 3358 zc_stop_midi();
7875 3358 currmidi=-1;
7876 3358 }
7877
7878 void System()
7879 {
7880 mouse_down=gui_mouse_b();
7881 music_pause();
7882 pause_all_sfx();
7883 MenuOpen = true;
7884 enter_sys_pal();
7885 // FONT *oldfont=font;
7886 // font=tfont;
7887
7888 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7889 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7890
7891 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7892 #if DEVLEVEL > 1
7893 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7894 #endif
7895 game_menu[3].flags =
7896 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7897 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7898 clear_keybuf();
7899
7900 DIALOG_PLAYER *p;
7901
7902 clear_bitmap(menu_bmp);
7903 oldscreen = screen;
7904 screen = menu_bmp;
7905
7906 p = init_dialog(system_dlg,-1);
7907
7908 // drop the menu on startup if menu button pressed
7909 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7910 simulate_keypress(KEY_G << 8);
7911
7912 do
7913 {
7914 if(close_button_quit)
7915 {
7916 close_button_quit = false;
7917 f_Quit(qEXIT);
7918 if(Quit) break;
7919 }
7920 rest(17);
7921
7922 if(mouse_down && !gui_mouse_b())
7923 mouse_down=0;
7924
7925 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7926 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7927 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7928
7929 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7930 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7931 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7932 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7933 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7934 settings_menu[10].flags = NESquit?D_SELECTED:0;
7935 settings_menu[11].flags = volkeys?D_SELECTED:0;
7936
7937 window_menu[0].flags = DragAspect?D_SELECTED:0;
7938 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7939 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7940 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7941 window_menu[4].flags = stretchGame?D_SELECTED:0;
7942
7943 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7944 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
7945
7946 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7947 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7948 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7949
7950 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7951 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7952 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7953
7954 bool nocheat = (replay_is_replaying() || !Playing
7955 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7956 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7957 cheat_menu[0].flags = 0;
7958 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7959 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7960 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7961 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7962 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7963 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7964 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7965 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7966 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7967
7968 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7969 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7970 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7971 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7972 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7973 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7974 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7975 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7976 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7977 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7978 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7979 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7980 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7981 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7982 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7983
7984 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7985 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7986
7987 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7988 (char *)"Disable recording new saves" :
7989 (char *)"Enable recording new saves";
7990 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7991 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7992 (char *)"Stop recording" :
7993 (char *)"Stop replaying";
7994 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7995 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7996 (char *)"Disable snapshot all frames" :
7997 (char *)"Enable snapshot all frames";
7998
7999 reset_snapshot_format_menu();
8000 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8001
8002 if(debug_enabled)
8003 {
8004 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8005 }
8006
8007 if(gui_mouse_b() && !mouse_down)
8008 break;
8009
8010 // press menu to drop the menu
8011 if(rMbtn())
8012 simulate_keypress(KEY_G << 8);
8013
8014 if(input_idle(true) > after_time())
8015 // run Screeen Saver
8016 {
8017 // Screen saver enabled for now.
8018 clear_keybuf();
8019 Matrix(ss_speed, ss_density, 0);
8020 system_pal(true);
8021 sys_mouse();
8022 broadcast_dialog_message(MSG_DRAW, 0);
8023 }
8024
8025 update_hw_screen();
8026 }
8027 while(update_dialog(p));
8028
8029 screen = oldscreen;
8030
8031 // font=oldfont;
8032 mouse_down=gui_mouse_b();
8033 shutdown_dialog(p);
8034 MenuOpen = false;
8035 if(Quit)
8036 {
8037 kill_sfx();
8038 music_stop();
8039 update_hw_screen();
8040 }
8041 else
8042 {
8043 music_resume();
8044 resume_all_sfx();
8045
8046 if(rc)
8047 ringcolor(false);
8048 }
8049 exit_sys_pal();
8050
8051 eat_buttons();
8052
8053 rc=false;
8054 clear_keybuf();
8055 // text_mode(0);
8056 }
8057
8058 46 void fix_dialogs()
8059 {
8060 46 jwin_center_dialog(about_dlg);
8061 46 jwin_center_dialog(gamepad_dlg);
8062 46 jwin_center_dialog(credits_dlg);
8063 46 jwin_center_dialog(gamemode_dlg);
8064 46 jwin_center_dialog(getnum_dlg);
8065 46 jwin_center_dialog(goto_dlg);
8066 46 jwin_center_dialog(keyboard_control_dlg);
8067 46 jwin_center_dialog(midi_dlg);
8068 46 jwin_center_dialog(quest_dlg);
8069 46 jwin_center_dialog(scrsaver_dlg);
8070 46 jwin_center_dialog(sound_dlg);
8071 46 jwin_center_dialog(triforce_dlg);
8072
8073 // digi_dp[1] += scrx;
8074 // digi_dp[2] += scry;
8075 // midi_dp[1] += scrx;
8076 // midi_dp[2] += scry;
8077 // pan_dp[1] += scrx;
8078 // pan_dp[2] += scry;
8079 // emus_dp[1] += scrx;
8080 // emus_dp[2] += scry;
8081 // buf_dp[1] += scrx;
8082 // buf_dp[2] += scry;
8083 // sfx_dp[1] += scrx;
8084 // sfx_dp[2] += scry;
8085 46 }
8086
8087 /*****************************/
8088 /**** Custom Sound System ****/
8089 /*****************************/
8090
8091 46 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8092 {
8093
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8094 }
8095
8096 // Run an NSF, or a MIDI if the NSF is missing somehow.
8097 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8098 {
8099 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8100
8101 // Found it
8102
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8103 {
8104 70 zcmusic_stop(zcmusic);
8105 70 zcmusic_unload_file(zcmusic);
8106 70 zc_stop_midi();
8107
8108 70 zcmusic=newzcmusic;
8109 70 zcmusic_play(zcmusic, emusic_volume);
8110
8111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8112 70 zcmusic_change_track(zcmusic,track);
8113
8114 70 return true;
8115 }
8116
8117 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8118
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8119 jukebox(midi);
8120
8121 79 return false;
8122 149 }
8123
8124 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8125 {
8126 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8127 // Found it
8128 if(newzcmusic!=NULL)
8129 {
8130 zcmusic_stop(zcmusic);
8131 zcmusic_unload_file(zcmusic);
8132 zc_stop_midi();
8133
8134 zcmusic=newzcmusic;
8135 zcmusic_play(zcmusic, emusic_volume);
8136
8137 if(track>0)
8138 zcmusic_change_track(zcmusic,track);
8139
8140 return true;
8141 }
8142
8143 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8144 else if(midi>-1000)
8145 jukebox(midi);
8146
8147 return false;
8148 }
8149
8150 int32_t get_zcmusicpos()
8151 {
8152 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8153 return debugtracething;
8154 return 0;
8155 }
8156
8157 void set_zcmusicpos(int32_t position)
8158 {
8159 zcmusic_set_curpos(zcmusic, position);
8160 }
8161
8162 void set_zcmusicspeed(int32_t speed)
8163 {
8164 int32_t newspeed = vbound(speed, 0, 10000);
8165 zcmusic_set_speed(zcmusic, newspeed);
8166 }
8167
8168 63871 void jukebox(int32_t index,int32_t loop)
8169 {
8170
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8171 63871 return;
8172
8173 music_stop();
8174
8175 if(index<0) index=MAXMIDIS-1;
8176
8177 if(index>=MAXMIDIS) index=0;
8178
8179 music_stop();
8180
8181 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8182 // stuck notes when a song stops. This fixes it.
8183 if(strcmp(midi_driver->name, "DIGMID")==0)
8184 zc_set_volume(0, 0);
8185
8186 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8187 zc_play_midi((MIDI*)tunes[index].data,loop);
8188
8189 if(tunes[index].start>0)
8190 zc_midi_seek(tunes[index].start);
8191
8192 midi_loop_start = tunes[index].loop_start;
8193 midi_loop_end = tunes[index].loop_end;
8194
8195 currmidi=index;
8196 master_volume(digi_volume,midi_volume);
8197 63871 }
8198
8199 63871 void jukebox(int32_t index)
8200 {
8201
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8202
8203
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8204
8205 // do nothing if it's already playing
8206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8207 {
8208 return;
8209 }
8210
8211 63871 jukebox(index,tunes[index].loop);
8212 63871 }
8213
8214 16 void play_DmapMusic()
8215 {
8216
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8217 16 return;
8218
8219 static char tfile[2048];
8220 static int32_t ttrack=0;
8221 bool domidi=false;
8222
8223 if(DMaps[currdmap].tmusic[0]!=0)
8224 {
8225 if(zcmusic==NULL ||
8226 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8227 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8228 {
8229 if(zcmusic != NULL)
8230 {
8231 zcmusic_stop(zcmusic);
8232 zcmusic_unload_file(zcmusic);
8233 zcmusic = NULL;
8234 }
8235
8236 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8237
8238 if(zcmusic!=NULL)
8239 {
8240 zc_stop_midi();
8241 strcpy(tfile,DMaps[currdmap].tmusic);
8242 zcmusic_play(zcmusic, emusic_volume);
8243 int32_t temptracks=0;
8244 temptracks=zcmusic_get_tracks(zcmusic);
8245 temptracks=(temptracks<2)?1:temptracks;
8246 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8247 zcmusic_change_track(zcmusic,ttrack);
8248 }
8249 else
8250 {
8251 tfile[0] = 0;
8252 domidi=true;
8253 }
8254 }
8255 }
8256 else
8257 {
8258 domidi=true;
8259 }
8260
8261 if(domidi)
8262 {
8263 int32_t m=DMaps[currdmap].midi;
8264
8265 switch(m)
8266 {
8267 case 1:
8268 jukebox(ZC_MIDI_OVERWORLD);
8269 break;
8270
8271 case 2:
8272 jukebox(ZC_MIDI_DUNGEON);
8273 break;
8274
8275 case 3:
8276 jukebox(ZC_MIDI_LEVEL9);
8277 break;
8278
8279 default:
8280 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8281 jukebox(m+MIDIOFFSET_DMAP);
8282 else
8283 music_stop();
8284 }
8285 }
8286 16 }
8287
8288 15753 void playLevelMusic()
8289 {
8290
1/2
✓ Branch 0 taken 15753 times.
✗ Branch 1 not taken.
15753 if (is_headless())
8291 15753 return;
8292
8293 int32_t m=tmpscr->screen_midi;
8294
8295 switch(m)
8296 {
8297 case -2:
8298 music_stop();
8299 break;
8300
8301 case -1:
8302 play_DmapMusic();
8303 break;
8304
8305 case 1:
8306 jukebox(ZC_MIDI_OVERWORLD);
8307 break;
8308
8309 case 2:
8310 jukebox(ZC_MIDI_DUNGEON);
8311 break;
8312
8313 case 3:
8314 jukebox(ZC_MIDI_LEVEL9);
8315 break;
8316
8317 default:
8318 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8319 jukebox(m+MIDIOFFSET_MAPSCR);
8320 else
8321 music_stop();
8322 }
8323 15753 }
8324
8325 46 void master_volume(int32_t dv,int32_t mv)
8326 {
8327
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
46 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8328
8329
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
46 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8330
8331
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
46 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8332 46 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8333 46 }
8334
8335 /*****************/
8336 /***** SFX *****/
8337 /*****************/
8338
8339 // array of voices, one for each sfx sample in the data file
8340 // 0+ = voice #
8341 // -1 = voice not allocated
8342 46 void Z_init_sound()
8343 {
8344
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 46 times.
11822 for(int32_t i=0; i<WAV_COUNT; i++)
8345 11776 sfx_voice[i]=-1;
8346
8347
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 46 times.
368 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8348 322 tunes[i].data = (MIDI*)mididata[i].dat;
8349
8350
2/2
✓ Branch 0 taken 11592 times.
✓ Branch 1 taken 46 times.
11638 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8351 11592 tunes[ZC_MIDI_COUNT+j].data=NULL;
8352
8353 46 master_volume(digi_volume,midi_volume);
8354 46 }
8355
8356 // returns number of voices currently allocated
8357 int32_t sfx_count()
8358 {
8359 int32_t c=0;
8360
8361 for(int32_t i=0; i<WAV_COUNT; i++)
8362 if(sfx_voice[i]!=-1)
8363 ++c;
8364
8365 return c;
8366 }
8367
8368 // clean up finished samples
8369 9216210 void sfx_cleanup()
8370 {
8371
2/2
✓ Branch 0 taken 2359349760 times.
✓ Branch 1 taken 9216210 times.
2368565970 for(int32_t i=0; i<WAV_COUNT; i++)
8372
3/4
✓ Branch 0 taken 619254 times.
✓ Branch 1 taken 2358730506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619254 times.
2359969014 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8373 {
8374 619254 deallocate_voice(sfx_voice[i]);
8375 619254 sfx_voice[i]=-1;
8376 619254 }
8377 9216210 }
8378
8379 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8380 // if a voice is already allocated (and/or playing), then it just returns true
8381 // Returns true: voice is allocated
8382 // false: unsuccessful
8383 963608 bool sfx_init(int32_t index)
8384 {
8385 // check index
8386
3/4
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721282 times.
963608 if(index<=0 || index>=WAV_COUNT)
8387 242326 return false;
8388
8389
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619271 times.
721282 if(sfx_voice[index]==-1)
8390 {
8391
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409395 times.
619271 if(sfxdat)
8392 {
8393
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8394 {
8395 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8396 209876 }
8397 else
8398 {
8399 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8400 }
8401 209876 }
8402 else
8403 {
8404 409395 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8405 }
8406
8407 619271 voice_set_volume(sfx_voice[index], sfx_volume);
8408 619271 }
8409
8410 721282 return sfx_voice[index] != -1;
8411 963608 }
8412
8413 // plays an sfx sample
8414 963608 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8415 {
8416
2/2
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
963608 if(!sfx_init(index))
8417 242326 return;
8418
8419
1/2
✓ Branch 0 taken 721282 times.
✗ Branch 1 not taken.
721282 if (!is_headless())
8420 {
8421 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8422 voice_set_pan(sfx_voice[index],pan);
8423
8424 int32_t pos = voice_get_position(sfx_voice[index]);
8425
8426 if(restart) voice_set_position(sfx_voice[index],0);
8427
8428 if(pos<=0)
8429 voice_start(sfx_voice[index]);
8430 }
8431
8432
3/4
✓ Branch 0 taken 398006 times.
✓ Branch 1 taken 323276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398006 times.
721282 if (restart && replay_is_debug())
8433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398006 times.
398006 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8434 963608 }
8435
8436 // true if sfx is allocated
8437 67537 bool sfx_allocated(int32_t index)
8438 {
8439
3/4
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9408 times.
67537 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8440 }
8441
8442 // start it (in loop mode) if it's not already playing,
8443 // otherwise adjust it to play in loop mode -DD
8444 178463 void cont_sfx(int32_t index)
8445 {
8446
1/2
✓ Branch 0 taken 178463 times.
✗ Branch 1 not taken.
178463 if (is_headless())
8447 178463 return;
8448
8449 if(!sfx_init(index))
8450 {
8451 return;
8452 }
8453
8454 if(voice_get_position(sfx_voice[index])<=0)
8455 {
8456 voice_set_position(sfx_voice[index],0);
8457 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8458 voice_start(sfx_voice[index]);
8459 }
8460 else
8461 {
8462 adjust_sfx(index, 128, true);
8463 }
8464 178463 }
8465
8466 // adjust parameters while playing
8467 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8468 {
8469
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8470 4075 return;
8471
8472 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8473 voice_set_pan(sfx_voice[index],pan);
8474 4075 }
8475
8476 // pauses a voice
8477 1725 void pause_sfx(int32_t index)
8478 {
8479
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8480 voice_stop(sfx_voice[index]);
8481 1725 }
8482
8483 // resumes a voice
8484 747 void resume_sfx(int32_t index)
8485 {
8486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8487 747 return;
8488
8489 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8490 voice_start(sfx_voice[index]);
8491 747 }
8492
8493 // pauses all active voices
8494 451 void pause_all_sfx()
8495 {
8496
2/2
✓ Branch 0 taken 115456 times.
✓ Branch 1 taken 451 times.
115907 for(int32_t i=0; i<WAV_COUNT; i++)
8497
2/2
✓ Branch 0 taken 115455 times.
✓ Branch 1 taken 1 times.
115457 if(sfx_voice[i]!=-1)
8498 1 voice_stop(sfx_voice[i]);
8499 451 }
8500
8501 // resumes all paused voices
8502 438 void resume_all_sfx()
8503 {
8504
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8505
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8506 voice_start(sfx_voice[i]);
8507 438 }
8508
8509 // stops an sfx and deallocates the voice
8510 7318087 void stop_sfx(int32_t index)
8511 {
8512
3/4
✓ Branch 0 taken 6167433 times.
✓ Branch 1 taken 1150654 times.
✓ Branch 2 taken 6167433 times.
✗ Branch 3 not taken.
7318087 if(index<=0 || index>=WAV_COUNT)
8513 1150654 return;
8514
8515
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6167422 times.
6167433 if(sfx_voice[index]!=-1)
8516 {
8517 11 deallocate_voice(sfx_voice[index]);
8518 11 sfx_voice[index]=-1;
8519 11 }
8520 7318087 }
8521
8522 // Stops SFX played by Hero's item of the given family
8523 128638 void stop_item_sfx(int32_t family)
8524 {
8525 128638 int32_t id=current_item_id(family);
8526
8527
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8528 128083 return;
8529
8530 555 stop_sfx(itemsbuf[id].usesound);
8531 128638 }
8532
8533 3220 void kill_sfx()
8534 {
8535
2/2
✓ Branch 0 taken 824320 times.
✓ Branch 1 taken 3220 times.
827540 for(int32_t i=0; i<WAV_COUNT; i++)
8536
2/2
✓ Branch 0 taken 824314 times.
✓ Branch 1 taken 6 times.
824326 if(sfx_voice[i]!=-1)
8537 {
8538 6 deallocate_voice(sfx_voice[i]);
8539 6 sfx_voice[i]=-1;
8540 6 }
8541 3220 }
8542
8543 659813 int32_t pan(int32_t x)
8544 {
8545
1/4
✓ Branch 0 taken 659813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659813 switch(pan_style)
8546 {
8547 case 0:
8548 return 128;
8549
8550 case 1:
8551 659813 return vbound((x>>1)+68,0,255);
8552
8553 case 2:
8554 return vbound(((x*3)>>2)+36,0,255);
8555 }
8556
8557 return vbound(x,0,255);
8558 659813 }
8559
8560 /*******************************/
8561 /******* Input Handlers ********/
8562 /*******************************/
8563
8564 25088805 bool joybtn(int32_t b)
8565 {
8566
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if(b == 0)
8567 return false;
8568
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if (b-1 >= joy[joystick_index].num_buttons)
8569 25088805 return false;
8570
8571 return joy[joystick_index].button[b-1].b !=0;
8572 25088805 }
8573
8574 const char* joybtn_name(int32_t b)
8575 {
8576 if (b <= 0 || b > joy[joystick_index].num_buttons)
8577 return "";
8578
8579 return joy[joystick_index].button[b-1].name;
8580 }
8581
8582 int32_t next_press_key();
8583
8584 int32_t next_press_btn()
8585 {
8586 clear_keybuf();
8587 /*bool b[joy[joystick_index].num_buttons+1];
8588
8589 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8590 b[i]=joybtn(i);*/
8591
8592 //first, we need to wait until they're pressing no buttons
8593 for(;;)
8594 {
8595 if(keypressed())
8596 {
8597 switch(readkey()>>8)
8598 {
8599 case KEY_ESC:
8600 return -1;
8601
8602 case KEY_SPACE:
8603 return 0;
8604 }
8605 }
8606
8607 poll_joystick();
8608 bool done = true;
8609
8610 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8611 {
8612 if(joybtn(i)) done = false;
8613 }
8614
8615 if(done) break;
8616 rest(1);
8617 }
8618
8619 //now, we need to wait for them to press any button
8620 for(;;)
8621 {
8622 if(keypressed())
8623 {
8624 switch(readkey()>>8)
8625 {
8626 case KEY_ESC:
8627 return -1;
8628
8629 case KEY_SPACE:
8630 return 0;
8631 }
8632 }
8633
8634 poll_joystick();
8635
8636 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8637 {
8638 if(joybtn(i)) return i;
8639 }
8640 rest(1);
8641 }
8642 }
8643
8644 1198535 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8645 {
8646
2/2
✓ Branch 0 taken 1194055 times.
✓ Branch 1 taken 4480 times.
1198535 bool ret = btn && !flag;
8647 1198535 flag = rawbtn;
8648
8649 1198535 return ret;
8650 }
8651 190895652 static bool rButton(bool &btn, bool &flag)
8652 {
8653
2/2
✓ Branch 0 taken 184052419 times.
✓ Branch 1 taken 6843233 times.
190895652 bool ret = btn && !flag;
8654 190895652 flag = btn;
8655
8656 190895652 return ret;
8657 }
8658 1846969 static bool rButtonPeek(bool btn, bool flag)
8659 {
8660
2/2
✓ Branch 0 taken 1644296 times.
✓ Branch 1 taken 202673 times.
1846969 if(!btn)
8661 {
8662 1644296 return false;
8663 }
8664
2/2
✓ Branch 0 taken 17699 times.
✓ Branch 1 taken 184974 times.
202673 else if(!flag)
8665 {
8666 17699 return true;
8667 }
8668
8669 184974 return false;
8670 1846969 }
8671
8672 // Updated only by keyboard/gamepad.
8673 // If in replay mode, this is set directly by the replay system.
8674 // This should never be read from directly - use control_state instead.
8675 bool raw_control_state[ZC_CONTROL_STATES];
8676
8677 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8678 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8679 // lasts until the next call to load_control_state.
8680 bool control_state[ZC_CONTROL_STATES];
8681 bool disable_control[ZC_CONTROL_STATES];
8682 bool drunk_toggle_state[11];
8683 bool disabledKeys[127];
8684 bool KeyInput[127];
8685 bool KeyPress[127];
8686
8687 bool key_current_frame[127];
8688 bool key_previous_frame[127];
8689
8690 static bool key_system[127];
8691 static bool key_system_previous[127];
8692 static bool key_system_press[127];
8693
8694 bool button_press[ZC_CONTROL_STATES];
8695 bool button_hold[ZC_CONTROL_STATES];
8696
8697 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8698 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8699 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8700 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8701 #define STICK_PRECISION 56 //define your own sensitivity
8702
8703 7799051 void load_control_state()
8704 {
8705 7799051 load_control_called_this_frame = true;
8706
8707
2/2
✓ Branch 0 taken 4831538 times.
✓ Branch 1 taken 2967513 times.
7799051 if (replay_version_check(8, 11))
8708 {
8709
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8710 53415234 down_control_states[i] = raw_control_state[i];
8711 2967513 }
8712
8713
1/2
✓ Branch 0 taken 7799051 times.
✗ Branch 1 not taken.
7799051 if (!replay_is_replaying())
8714 {
8715 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8716 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8717 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8718 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8719 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8720 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8721 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8722 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8723 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8724 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8725 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8726 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8727 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8728 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8729
8730 if(num_joysticks != 0)
8731 {
8732 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8733 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8734 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8735 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8736 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8737 }
8738 else
8739 {
8740 raw_control_state[14] = false;
8741 raw_control_state[15] = false;
8742 raw_control_state[16] = false;
8743 raw_control_state[17] = false;
8744 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8745 }
8746 }
8747
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799048 times.
7799051 if (replay_is_active())
8748 {
8749
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6783833 times.
7799048 if (replay_get_version() < 3)
8750 1015215 replay_poll();
8751
3/4
✓ Branch 0 taken 6783833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5022458 times.
✓ Branch 3 taken 1761375 times.
6783833 else if (replay_is_replaying() && replay_get_version() < 6)
8752 1761375 replay_peek_input();
8753
3/4
✓ Branch 0 taken 5022458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2054945 times.
✓ Branch 3 taken 2967513 times.
5022458 else if (replay_is_replaying() && replay_version_check(8, 11))
8754 2967513 replay_peek_input();
8755
2/2
✓ Branch 0 taken 6694758 times.
✓ Branch 1 taken 1104290 times.
7799048 if (replay_get_version() == 8)
8756 1104290 update_keys();
8757 7799048 }
8758
8759 // Some test replay files were made before a serious input bug was fixed, so instead
8760 // of re-doing them or tossing them out, just check for that zplay version.
8761
3/4
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677145 times.
7799051 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8762
2/2
✓ Branch 0 taken 140382810 times.
✓ Branch 1 taken 7799045 times.
148181855 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8763 {
8764 140382810 control_state[i] = raw_control_state[i];
8765
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90895500 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140382810 if (botched_input && !control_state[i])
8766 47077142 down_control_states[i] = false;
8767 140382810 }
8768 7799045 bool did_bad_cutscene_btn = false;
8769
2/2
✓ Branch 0 taken 7799045 times.
✓ Branch 1 taken 140382810 times.
148181855 for(int q = 0; q < 18; ++q)
8770
3/4
✓ Branch 0 taken 6462860 times.
✓ Branch 1 taken 133919950 times.
✓ Branch 2 taken 6462860 times.
✗ Branch 3 not taken.
140382810 if(control_state[q] && !active_cutscene.can_button(q))
8771 {
8772 control_state[q] = false;
8773 did_bad_cutscene_btn = true;
8774 }
8775
1/2
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
7799045 if(did_bad_cutscene_btn)
8776 active_cutscene.error();
8777
8778 7799045 button_press[0]=rButton(control_state[0],button_hold[0]);
8779 7799045 button_press[1]=rButton(control_state[1],button_hold[1]);
8780 7799045 button_press[2]=rButton(control_state[2],button_hold[2]);
8781 7799045 button_press[3]=rButton(control_state[3],button_hold[3]);
8782 7799045 button_press[4]=rButton(control_state[4],button_hold[4]);
8783 7799045 button_press[5]=rButton(control_state[5],button_hold[5]);
8784 7799045 button_press[6]=rButton(control_state[6],button_hold[6]);
8785 7799045 button_press[7]=rButton(control_state[7],button_hold[7]);
8786 7799045 button_press[8]=rButton(control_state[8],button_hold[8]);
8787 7799045 button_press[9]=rButton(control_state[9],button_hold[9]);
8788 7799045 button_press[10]=rButton(control_state[10],button_hold[10]);
8789 7799045 button_press[11]=rButton(control_state[11],button_hold[11]);
8790 7799045 button_press[12]=rButton(control_state[12],button_hold[12]);
8791 7799045 button_press[13]=rButton(control_state[13],button_hold[13]);
8792 7799045 button_press[14]=rButton(control_state[14],button_hold[14]);
8793 7799045 button_press[15]=rButton(control_state[15],button_hold[15]);
8794 7799045 button_press[16]=rButton(control_state[16],button_hold[16]);
8795 7799045 button_press[17]=rButton(control_state[17],button_hold[17]);
8796 7799045 }
8797
8798 // Returns true if any game key is pressed. This is needed because keypressed()
8799 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8800 40242214 bool zc_key_pressed()
8801 //may also need to use zc_getrawkey
8802 {
8803
7/10
✓ Branch 0 taken 32591229 times.
✓ Branch 1 taken 7650985 times.
✓ Branch 2 taken 7650985 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7650985 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6394916 times.
✓ Branch 7 taken 6394916 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461268 times.
42703482 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8804
4/6
✓ Branch 0 taken 6394916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6394916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843285 times.
✓ Branch 5 taken 4843285 times.
6394916 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8805
4/6
✓ Branch 0 taken 4843285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843285 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142666 times.
✓ Branch 5 taken 3142666 times.
4843285 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8806
4/6
✓ Branch 0 taken 3142666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731732 times.
✓ Branch 5 taken 2731732 times.
3142666 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8807
1/2
✓ Branch 0 taken 2731732 times.
✗ Branch 1 not taken.
2731732 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8808
3/4
✓ Branch 0 taken 2612325 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612325 times.
✗ Branch 3 not taken.
2731732 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8809
3/4
✓ Branch 0 taken 2493431 times.
✓ Branch 1 taken 118894 times.
✓ Branch 2 taken 2493431 times.
✗ Branch 3 not taken.
2612325 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8810
3/4
✓ Branch 0 taken 2478286 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478286 times.
✗ Branch 3 not taken.
2493431 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8811
3/4
✓ Branch 0 taken 2464787 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464787 times.
✗ Branch 3 not taken.
2478286 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8812
3/4
✓ Branch 0 taken 2462293 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462293 times.
✗ Branch 3 not taken.
2464787 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8813
3/4
✓ Branch 0 taken 2462103 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462103 times.
✗ Branch 3 not taken.
2462293 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8814
3/4
✓ Branch 0 taken 2461293 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461293 times.
✗ Branch 3 not taken.
2462103 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8815
3/4
✓ Branch 0 taken 2461287 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461287 times.
✗ Branch 3 not taken.
2461293 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8816
2/2
✓ Branch 0 taken 2461268 times.
✓ Branch 1 taken 19 times.
2461287 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8817 72006144 return true;
8818
8819 2461268 return false;
8820 9284954 }
8821
8822 149218891 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8823 {
8824 149218891 bool ret = false, drunkstate = false, rawret = false;;
8825 149218891 bool* flag = &down_control_states[btn];
8826
2/7
✓ Branch 0 taken 139924601 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294290 times.
149218891 switch(btn)
8827 {
8828 case btnF12:
8829 ret = zc_getkey(KEY_F12, ignoreDisable);
8830 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8831 eatEntirely = false;
8832 break;
8833 case btnF11:
8834 ret = zc_getkey(KEY_F11, ignoreDisable);
8835 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8836 eatEntirely = false;
8837 break;
8838 case btnF5:
8839 ret = zc_getkey(KEY_F5, ignoreDisable);
8840 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8841 eatEntirely = false;
8842 break;
8843 case btnQ:
8844 ret = zc_getkey(KEY_Q, ignoreDisable);
8845 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8846 eatEntirely = false;
8847 break;
8848 case btnI:
8849 ret = zc_getkey(KEY_I, ignoreDisable);
8850 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8851 eatEntirely = false;
8852 break;
8853 case btnM:
8854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294290 times.
9294290 if(FFCore.kb_typing_mode) return false;
8855 9294290 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8856 9294290 eatEntirely = false;
8857 9294290 break;
8858 default: //control_state[] index
8859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139924601 times.
139924601 if(FFCore.kb_typing_mode) return false;
8860
5/6
✓ Branch 0 taken 139125144 times.
✓ Branch 1 taken 799457 times.
✓ Branch 2 taken 2190363 times.
✓ Branch 3 taken 136934781 times.
✓ Branch 4 taken 2190363 times.
✗ Branch 5 not taken.
139924601 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8861
2/2
✓ Branch 0 taken 7643662 times.
✓ Branch 1 taken 132280939 times.
139924601 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8862
4/4
✓ Branch 0 taken 125762927 times.
✓ Branch 1 taken 14161674 times.
✓ Branch 2 taken 2995 times.
✓ Branch 3 taken 14158679 times.
154086275 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8863 139924601 rawret = raw_control_state[btn];
8864 139924601 }
8865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149218891 times.
149218891 assert(flag);
8866
2/2
✓ Branch 0 taken 95660545 times.
✓ Branch 1 taken 53558346 times.
149218891 if(press)
8867 {
8868
2/2
✓ Branch 0 taken 1846969 times.
✓ Branch 1 taken 51711377 times.
53558346 if(peek)
8869 1846969 ret = rButtonPeek(ret, *flag);
8870
2/2
✓ Branch 0 taken 50512842 times.
✓ Branch 1 taken 1198535 times.
51711377 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8871 1198535 else ret = rButton(ret, *flag, rawret);
8872 53558346 }
8873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149218891 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149218891 if(eatEntirely && ret) control_state[btn] = false;
8874
3/4
✓ Branch 0 taken 112177277 times.
✓ Branch 1 taken 37041614 times.
✓ Branch 2 taken 112177277 times.
✗ Branch 3 not taken.
149218891 if(drunk && drunkstate) ret = !ret;
8875 149218891 return ret;
8876 149218891 }
8877
8878 7333007 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8879 {
8880 7333007 byte ret = 0;
8881
2/2
✓ Branch 0 taken 5483939 times.
✓ Branch 1 taken 1849068 times.
7333007 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8882
2/2
✓ Branch 0 taken 7332445 times.
✓ Branch 1 taken 562 times.
7333007 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8883
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8884
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8885
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8886
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8887
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8888
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8889 7333007 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8890 }
8891
8892 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8893 {
8894 1114 return intbtn&vals;
8895 }
8896
8897 1767241 bool Up()
8898 {
8899 1767241 return getInput(btnUp);
8900 }
8901 146943 bool Down()
8902 {
8903 146943 return getInput(btnDown);
8904 }
8905 257358 bool Left()
8906 {
8907 257358 return getInput(btnLeft);
8908 }
8909 286551 bool Right()
8910 {
8911 286551 return getInput(btnRight);
8912 }
8913 164908 bool cAbtn()
8914 {
8915 164908 return getInput(btnA);
8916 }
8917 1411891 bool cBbtn()
8918 {
8919 1411891 return getInput(btnB);
8920 }
8921 bool cSbtn()
8922 {
8923 return getInput(btnS);
8924 }
8925 68744 bool cLbtn()
8926 {
8927 68744 return getInput(btnL);
8928 }
8929 68744 bool cRbtn()
8930 {
8931 68744 return getInput(btnR);
8932 }
8933 bool cPbtn()
8934 {
8935 return getInput(btnP);
8936 }
8937 bool cEx1btn()
8938 {
8939 return getInput(btnEx1);
8940 }
8941 bool cEx2btn()
8942 {
8943 return getInput(btnEx2);
8944 }
8945 bool cEx3btn()
8946 {
8947 return getInput(btnEx3);
8948 }
8949 bool cEx4btn()
8950 {
8951 return getInput(btnEx4);
8952 }
8953 bool AxisUp()
8954 {
8955 return getInput(btnAxisUp);
8956 }
8957 bool AxisDown()
8958 {
8959 return getInput(btnAxisDown);
8960 }
8961 bool AxisLeft()
8962 {
8963 return getInput(btnAxisLeft);
8964 }
8965 bool AxisRight()
8966 {
8967 return getInput(btnAxisRight);
8968 }
8969
8970 bool cMbtn()
8971 {
8972 return getInput(btnM);
8973 }
8974 bool cF12()
8975 {
8976 return getInput(btnF12);
8977 }
8978 bool cF11()
8979 {
8980 return getInput(btnF11);
8981 }
8982 bool cF5()
8983 {
8984 return getInput(btnF5);
8985 }
8986 bool cQ()
8987 {
8988 return getInput(btnQ);
8989 }
8990 bool cI()
8991 {
8992 return getInput(btnI);
8993 }
8994
8995 130270 bool rUp()
8996 {
8997 130270 return getInput(btnUp, true);
8998 }
8999 130174 bool rDown()
9000 {
9001 130174 return getInput(btnDown, true);
9002 }
9003 130122 bool rLeft()
9004 {
9005 130122 return getInput(btnLeft, true);
9006 }
9007 129657 bool rRight()
9008 {
9009 129657 return getInput(btnRight, true);
9010 }
9011 3145 bool rAbtn()
9012 {
9013 3145 return getInput(btnA, true);
9014 }
9015 131548 bool rBbtn()
9016 {
9017 131548 return getInput(btnB, true);
9018 }
9019 7395153 bool rSbtn()
9020 {
9021 7395153 return getInput(btnS, true);
9022 }
9023 9284954 bool rMbtn()
9024 {
9025 9284954 return getInput(btnM, true);
9026 }
9027 129441 bool rLbtn()
9028 {
9029 129441 return getInput(btnL, true);
9030 }
9031 129436 bool rRbtn()
9032 {
9033 129436 return getInput(btnR, true);
9034 }
9035 7331617 bool rPbtn()
9036 {
9037 7331617 return getInput(btnP, true);
9038 }
9039 bool rEx1btn()
9040 {
9041 return getInput(btnEx1, true);
9042 }
9043 bool rEx2btn()
9044 {
9045 return getInput(btnEx2, true);
9046 }
9047 140087 bool rEx3btn()
9048 {
9049 140087 return getInput(btnEx3, true);
9050 }
9051 140087 bool rEx4btn()
9052 {
9053 140087 return getInput(btnEx4, true);
9054 }
9055 bool rAxisUp()
9056 {
9057 return getInput(btnAxisUp, true);
9058 }
9059 bool rAxisDown()
9060 {
9061 return getInput(btnAxisDown, true);
9062 }
9063 bool rAxisLeft()
9064 {
9065 return getInput(btnAxisLeft, true);
9066 }
9067 bool rAxisRight()
9068 {
9069 return getInput(btnAxisRight, true);
9070 }
9071
9072 bool rF11()
9073 {
9074 return getInput(btnF11, true);
9075 }
9076 bool rQ()
9077 {
9078 return getInput(btnQ, true);
9079 }
9080 bool rI()
9081 {
9082 return getInput(btnI, true);
9083 }
9084
9085 18221767 bool DrunkUp()
9086 {
9087 18221767 return getInput(btnUp, false, true);
9088 }
9089 16885102 bool DrunkDown()
9090 {
9091 16885102 return getInput(btnDown, false, true);
9092 }
9093 10286365 bool DrunkLeft()
9094 {
9095 10286365 return getInput(btnLeft, false, true);
9096 }
9097 8832532 bool DrunkRight()
9098 {
9099 8832532 return getInput(btnRight, false, true);
9100 }
9101 8034063 bool DrunkcAbtn()
9102 {
9103 8034063 return getInput(btnA, false, true);
9104 }
9105 7848592 bool DrunkcBbtn()
9106 {
9107 7848592 return getInput(btnB, false, true);
9108 }
9109 7262487 bool DrunkcEx1btn()
9110 {
9111 7262487 return getInput(btnEx1, false, true);
9112 }
9113 7262507 bool DrunkcEx2btn()
9114 {
9115 7262507 return getInput(btnEx2, false, true);
9116 }
9117 bool DrunkcSbtn()
9118 {
9119 return getInput(btnS, false, true);
9120 }
9121 bool DrunkcMbtn()
9122 {
9123 return getInput(btnM, false, true);
9124 }
9125 bool DrunkcLbtn()
9126 {
9127 return getInput(btnL, false, true);
9128 }
9129 bool DrunkcRbtn()
9130 {
9131 return getInput(btnR, false, true);
9132 }
9133 bool DrunkcPbtn()
9134 {
9135 return getInput(btnP, false, true);
9136 }
9137
9138 bool DrunkrUp()
9139 {
9140 return getInput(btnUp, true, true);
9141 }
9142 bool DrunkrDown()
9143 {
9144 return getInput(btnDown, true, true);
9145 }
9146 bool DrunkrLeft()
9147 {
9148 return getInput(btnLeft, true, true);
9149 }
9150 bool DrunkrRight()
9151 {
9152 return getInput(btnRight, true, true);
9153 }
9154 6080192 bool DrunkrAbtn()
9155 {
9156 6080192 return getInput(btnA, true, true);
9157 }
9158 6097024 bool DrunkrBbtn()
9159 {
9160 6097024 return getInput(btnB, true, true);
9161 }
9162 71669 bool DrunkrEx1btn()
9163 {
9164 71669 return getInput(btnEx1, true, true);
9165 }
9166 71662 bool DrunkrEx2btn()
9167 {
9168 71662 return getInput(btnEx2, true, true);
9169 }
9170 bool DrunkrEx3btn()
9171 {
9172 return getInput(btnEx3, true, true);
9173 }
9174 bool DrunkrEx4btn()
9175 {
9176 return getInput(btnEx4, true, true);
9177 }
9178 bool DrunkrSbtn()
9179 {
9180 return getInput(btnS, true, true);
9181 }
9182 bool DrunkrMbtn()
9183 {
9184 return getInput(btnM, true, true);
9185 }
9186 6687269 bool DrunkrLbtn()
9187 {
9188 6687269 return getInput(btnL, true, true);
9189 }
9190 6683794 bool DrunkrRbtn()
9191 {
9192 6683794 return getInput(btnR, true, true);
9193 }
9194 bool DrunkrPbtn()
9195 {
9196 return getInput(btnP, true, true);
9197 }
9198
9199 9336 void eat_buttons()
9200 {
9201 9336 getInput(btnA, true, false, true);
9202 9336 getInput(btnB, true, false, true);
9203 9336 getInput(btnS, true, false, true);
9204 9336 getInput(btnM, true, false, true);
9205 9336 getInput(btnL, true, false, true);
9206 9336 getInput(btnR, true, false, true);
9207 9336 getInput(btnP, true, false, true);
9208 9336 getInput(btnEx1, true, false, true);
9209 9336 getInput(btnEx2, true, false, true);
9210 9336 getInput(btnEx3, true, false, true);
9211 9336 getInput(btnEx4, true, false, true);
9212 9336 }
9213
9214 // Is true for the _first frame_ of a key press.
9215 // But! it is possible that a script manually sets the value of KeyPress,
9216 // in which case it will be restored to the "true" value based on `key_current_frame`
9217 // and `key_previous_frame` on the next frame.
9218 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9219 {
9220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9222 {
9223 case KEY_F7:
9224 case KEY_F8:
9225 case KEY_F9:
9226 return KeyPress[k];
9227
9228 default:
9229
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9230 }
9231 13 }
9232
9233 // Is true for _every frame_ a key is held down.
9234 // But! it is possible that a script manually sets the value of KeyInput,
9235 // in which case it will be restored to the "true" value based on `key_current_frame`
9236 // on the next frame.
9237 bool zc_getkey(int32_t k, bool ignoreDisable)
9238 {
9239 if(ignoreDisable) return KeyInput[k];
9240 switch(k)
9241 {
9242 case KEY_F7:
9243 case KEY_F8:
9244 case KEY_F9:
9245 return KeyInput[k];
9246
9247 default:
9248 return KeyInput[k] && !disabledKeys[k];
9249 }
9250 }
9251
9252 // Reads (and then clears) the current frame key state directly.
9253 // Scripts can also modify `key_current_frame`.
9254 300 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9255 {
9256
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 298 times.
300 if(zc_getrawkey(k, ignoreDisable))
9257 {
9258 2 _key[k]=key[k]=key_current_frame[k]=0;
9259 2 return true;
9260 }
9261 298 _key[k]=key[k]=key_current_frame[k]=0;
9262 298 return false;
9263 300 }
9264
9265 // Reads the current frame key state directly.
9266 // Scripts can also modify `key_current_frame`.
9267 63238933 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9268 {
9269
2/2
✓ Branch 0 taken 53953953 times.
✓ Branch 1 taken 9284980 times.
63238933 if(ignoreDisable) return key_current_frame[k];
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 switch(k)
9271 {
9272 case KEY_F7:
9273 case KEY_F8:
9274 case KEY_F9:
9275 return key_current_frame[k];
9276
9277 default:
9278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 return key_current_frame[k] && !disabledKeys[k];
9279 }
9280 63238933 }
9281
9282 // Only used for a handful of keys, like tilde and Function keys.
9283 // This state is never read within the game.
9284 // It exists so that all keyboard input still functions during replay,
9285 // without inadvertently doing things like toggling throttling if the player
9286 // presses ~
9287 9284954 bool zc_get_system_key(int32_t k)
9288 {
9289 9284954 return key_system[k];
9290 }
9291
9292 // True for the _first_ frame of a key press.
9293 83564586 bool zc_read_system_key(int32_t k)
9294 {
9295 83564586 return key_system_press[k];
9296 }
9297
9298 1179189158 bool is_system_key(int32_t k)
9299 {
9300
2/2
✓ Branch 0 taken 1095624572 times.
✓ Branch 1 taken 83564586 times.
1179189158 switch (k)
9301 {
9302 case KEY_BACKQUOTE:
9303 case KEY_CLOSEBRACE:
9304 case KEY_END:
9305 case KEY_HOME:
9306 case KEY_OPENBRACE:
9307 case KEY_PGDN:
9308 case KEY_PGUP:
9309 case KEY_TAB:
9310 case KEY_TILDE:
9311 83564586 return true;
9312 }
9313 1095624572 return is_Fkey(k);
9314 1179189158 }
9315
9316 9284954 void update_system_keys()
9317 {
9318
2/2
✓ Branch 0 taken 1179189158 times.
✓ Branch 1 taken 9284954 times.
1188474112 for (int32_t q = 0; q < 127; ++q)
9319 {
9320
2/2
✓ Branch 0 taken 194984034 times.
✓ Branch 1 taken 984205124 times.
1179189158 if (!is_system_key(q))
9321 984205124 continue;
9322
9323 194984034 key_system[q] = key[q];
9324
1/2
✓ Branch 0 taken 194984034 times.
✗ Branch 1 not taken.
194984034 key_system_press[q] = key_system[q] && !key_system_previous[q];
9325 194984034 key_system_previous[q] = key_system[q];
9326 194984034 }
9327 9284954 }
9328
9329 10389244 void update_keys()
9330 {
9331
2/2
✓ Branch 0 taken 1319433988 times.
✓ Branch 1 taken 10389244 times.
1329823232 for (int32_t q = 0; q < 127; ++q)
9332 {
9333 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9334
1/2
✓ Branch 0 taken 1319433988 times.
✗ Branch 1 not taken.
1319433988 if (!replay_is_replaying())
9335 key_current_frame[q] = key[q];
9336
9337
2/2
✓ Branch 0 taken 1309647613 times.
✓ Branch 1 taken 9786375 times.
1319433988 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9338 1319433988 KeyInput[q] = key_current_frame[q];
9339 1319433988 key_previous_frame[q] = key_current_frame[q];
9340 1319433988 }
9341 10389244 }
9342
9343 bool zc_disablekey(int32_t k, bool val)
9344 {
9345 switch(k)
9346 {
9347 case KEY_F7:
9348 case KEY_F8:
9349 case KEY_F9:
9350 return false;
9351
9352 default:
9353 disabledKeys[k] = val;
9354 return true;
9355 }
9356 }
9357
9358 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9359 {
9360 timer=timer;
9361 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9362 }
9363